View Full Version : Resolved sql array results

03-29-2010, 06:06 PM
I've only been able to get this to show one game from the database, but I like it to display 5 games, I've tried "while" statement and yet that comes back false

limit = 5 (I want to show 5 results) this code is outputting only 1 result.

$sql = "SELECT * FROM games_info LIMIT 5";
$runSql = $dbBroker->arcade->fetchAll($sql);

foreach($runSql as $game)
print_r($game);echo "<br />";

Thanks for anyone that can help me get the array function to work properly.

03-29-2010, 06:17 PM
Could you please post the function fetchAll()?

03-29-2010, 06:19 PM
Could you please post the function fetchAll()?

Right now i've got (includes built in APC cache)

public function fetchAll($query,$ttl = 0,$resultmode = null){

if($ttl > 0){

$key = md5($query);
if(!$result = apc_fetch($key)){
$result = parent::query($query,$resultmode)->fetch_object();

return $result;

//return parent::query($query,$resultmode)->fetch_object();
if($return = parent::query($query,$resultmode)){
return $return->fetch_object();
return array();


03-29-2010, 09:27 PM
FetchAll's job appears to be to fetch each of the columns, not the rows.
MySQLi has a builtin method called fetch_all. If you use that one, $resultmode will have to be given a valid default. That will take more memory though compared to the while fetch. The end result should be about the same memory usage.

03-29-2010, 09:34 PM
Yeah thanks, actually deceided to build another function to handle with the array method.

private function _buildArray(mysqli_result $result)

so far things have come along okay. ;)

Thanks for input!