private function countAllRecords()Originariamente inviato da filippo.toso
L'utilizzo che fai di return è piuttosto strano.
{
/* if the record count isn't already cached in the session,
read the value from the database */
if (!isset($_SESSION['record_count']))
{
// the query that returns the record count
$count_query = 'SELECT COUNT(*) FROM product';
// execute the query and fetch the result
if ($result = $this->mMysqli->query($count_query))
{
// retrieve the first returned row
$row = $result->fetch_row();
/* retrieve the first column of the first row (it represents the
records count that we were looking for), and save its value in
the session */
$_SESSION['record_count'] = $row[0];
// close the database handle
$result->close();
}
}
// read the record count from the session and return it
return $_SESSION['record_count'];
}