/** * @todo This looks terrible but there is no SQLite3::get_num_rows() implementation */ public function numRecords() { $c = 0; while ($this->handle->fetchArray()) { $c++; } $this->handle->reset(); return $c; }
/** * @param SQLite3Result $result * @return int */ public function num_rows($result) { $num_rows = 0; while ($result->fetchArray()) { $num_rows++; } $result->reset(); return $num_rows; }
/** * Number of rows in a result. * * @param SQLite3Result $result * @return integer */ public function numRows($result) { !isset($result->fetchedByPMF) || !$result->fetchedByPMF || die("Do not call numRows() after you've fetched one or more result records, because PMF_DB_Sqlite3::numRows() has to reset the resultset at its end."); $numberOfRows = 0; while ($result->fetchArray(SQLITE3_NUM)) { $numberOfRows++; } $result->reset(); return $numberOfRows; }
function __construct($result) { $this->result = $result; $this->recordAvailable = $this->result->fetchArray() !== false; $this->result->reset(); }