/** 排序用任务函数(降序 由usort()挪用)
*/
function _cmp_desc($a,$b) {
global $cmp_key;
if ($a[$cmp_key] == $b[$cmp_key]) return 0;
return ($a[$cmp_key] > $b[$cmp_key]) ? -1 : 1;
}
/** 排序用任务函数(升序 由usort()挪用)
*/
function _cmp_asc($a,$b) {
global $cmp_key;
if ($a[$cmp_key] == $b[$cmp_key]) return 0;
return ($a[$cmp_key] > $b[$cmp_key]) ? 1 : -1;
}
?>
测试例:
<pre>
<?php
//require_once "db_text.php";
$conn = new DB_text;
$conn->connect("text1.txt");
$conn->query("insert into manage (id,title) values (10,'abcd')");
$conn->query("insert into manage (id,title) values (2,'43d')");
$conn->query("insert into manage (id,title) values (20,'tuu')");
$conn->query("update manage set id=101,test='a' where id=10");
//$conn->query("delete from manage where id='10'");
//$conn->query("delete from manage where id=10 or table='code'");
//$rt = $conn->query("select * from manage where id=101 or table='code' group by 1 order by 1 asc");
$rt = $conn->query("select * from manage group by 1 order by id desc");