39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
// File name: fetchrec.inc.php
|
|
// Description: PHP subroutine to fetch items from the database
|
|
// Date: 2004-05-26
|
|
// Author: imacat <imacat@pristine.com.tw>
|
|
// Copyright: Copyright (C) 2004-2007 Pristine Communications
|
|
|
|
// Set the include path
|
|
if (!defined("INCPATH_SET")) {
|
|
require_once dirname(__FILE__) . "/incpath.inc.php";
|
|
}
|
|
// Referenced subroutines
|
|
require_once "monica/chkfunc.inc.php";
|
|
require_once "monica/getlang.inc.php";
|
|
require_once "monica/lninfo.inc.php";
|
|
require_once "monica/sql.inc.php";
|
|
|
|
// fetchrec: Try to fetch a record by its serial number
|
|
function fetchrec(&$sn, $table)
|
|
{
|
|
if (!check_sn($sn)) {
|
|
return false;
|
|
}
|
|
$select = "SELECT * FROM $table WHERE sn=$sn;\n";
|
|
$result = sql_query($select);
|
|
if (sql_num_rows($result) != 1) {
|
|
return false;
|
|
}
|
|
$row = sql_fetch_assoc($result);
|
|
// Hash the multi-lingual columns
|
|
foreach (sql_cols_ml($table) as $col) {
|
|
$row[$col] = $row[$col . "_" . getlang(LN_DATABASE)];
|
|
}
|
|
return $row;
|
|
}
|
|
|
|
|
|
?>
|