请php里面有没有对从数据库搜索出来的记录进行movenext操作的函数呢?
我用php里面的mysql_fetch_array()函数取记录时,它总会自动movenext到下一条记录去。我却想把取记录与移动记录的操作分成两个操作去处理。而php里所提供的mysql_fetch_array()函数却两个操作都合成在一起实现。
谢谢。
说说你的目的吧
或许有其他办法解决
可以使用db类来解决呀,比如phplib DB, PEAR::DB都有类似类似方法。
对pear::db类的next封装:
function next($format = SQL_INDEX) {
// fetch mode (index or associative)
$_fetchmode = ($format == SQL_ASSOC) ? DB_FETCHMODE_ASSOC : null;
if ($this->record = $this->result->fetchRow($_fetchmode)) {
return true;
} else {
$this->result->free();
return false;
}
}
http://smarty.php.net/sampleapp/sampleapp_p3.php
$sql = "select * from table";
$rs = $db->Execute($sql);
while (!$rs->EOF) {
//print_r($rs->fields);
//上一次作输出用
$rs->MoveNext();
}