数据库操作函数db 1. [代码] [PHP]代码 ?phprequire_once 'mysql.php';//------------------------------------------------------------------------------//...function QueryAsXml($sql){global $db;$db-query($sql);$Array = array();$i = 0;
1. [代码][PHP]代码
<?php require_once 'mysql.php'; //------------------------------------------------------------------------------ //... function QueryAsXml($sql) { global $db; $db->query($sql); $Array = array(); $i = 0; //... $ret = ""; //返回xml记录 $PRec = 0; //当前记录指针 $FName = ""; //列名称 $FNums = $db->num_fields(); //列数量 $Rows = 0; //记录数量 while($db->next_record()) { $id = $db->Query_ID; $ret = $ret . "<item" . $Rows . ">"; for ($i = 0; $i<$FNums; $i++) { $FName = @mysql_field_name($id, $i); $ret = $ret . "<" . $FName . ">"; $ret = $ret . $db->Record[$i]; $ret = $ret . "</" . $FName . ">"; } $ret = $ret . "</item" . $Rows . ">" . "\n"; $Rows = $Rows+1; } return $ret; } //------------------------------------------------------------------------------ //... function QueryAsXml2($sql) { global $db; $db->query($sql); $Array = array(); $i = 0; //... $ret = ""; //返回xml记录 $PRec = 0; //当前记录指针 $FName = ""; //列名称 $FNums = $db->num_fields(); //列数量 $Rows = 0; //记录数量 while($db->next_record()) { $id = $db->Query_ID; //$ret = $ret . "<item" . $Rows . ">"; //echo $id; for ($i = 0; $i<$FNums; $i++) { $FName = @mysql_field_name($id, $i); $ret = $ret . "<" . $FName . ">"; $ret = $ret . $db->Record[$i]; $ret = $ret . "</" . $FName . ">"; } //$ret = $ret . "</item" . $Rows . ">" . "\n"; $ret = $ret . ";\n"; $Rows = $Rows+1; } return $ret; } //------------------------------------------------------------------------------ //... function QueryAsArray($sql, $split) { global $db; $db->query($sql); $Array = array(); $i = 0; //... $ret = ""; //返回xml记录 $PRec = 0; //当前记录指针 $FName = ""; //列名称 $FNums = $db->num_fields(); //列数量 $Rows = 0; //记录数量 while($db->next_record()) { $id = $db->Query_ID; $ret = $ret . "["; for ($i = 0; $i<$FNums; $i++) { $FName = @mysql_field_name($id, $i); $ret = $ret . $db->Record[$i] . $split; } $ret = $ret . "]" . "\n"; $Rows = $Rows+1; } return $ret; } function ExecSql($sql) { global $db; $db->query($sql); $j= 0; $Array = array(); while($db->next_record()) { $Array[$j]= $db->Record; $j++; } return $Array; } ?>