Initial commit.
This commit is contained in:
38
lib/php/monica/fetchrec.inc.php
Normal file
38
lib/php/monica/fetchrec.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user