FetchObject/Database bug?

1 view
Skip to first unread message

Palantar

unread,
Apr 30, 2008, 9:10:16 PM4/30/08
to Php Object Generator
Heyas Joel, just wondering - this looks like a bug to me, but
obviously you'll know better. in the POG base class, FetchObjects/
CreateObjects appears to be expecting the database query to return a
valid mysql_result, but it is returning the number of rows instead. I
get an error every time I use it.

The current database object looks like this:

public static function Query($query, $connection)
{
$result = mysql_query($query, $connection);
return mysql_num_rows($result);
}

the current FetchObject code (relevant portions) looks like this:

public function FetchObjects($query, $objectClass, $lazy = true)
{
$databaseConnection = Database::Connect();
$result = Database::Query($query, $databaseConnection);
$objectList = $this->CreateObjects($result, $objectClass, $lazy);
return $objectList;
}

private function CreateObjects($mysql_result, $objectClass, $lazyLoad
= true)
{
$objectList = array();
while ($row = mysql_fetch_assoc($mysql_result))
{
$pog_object = new $objectClass();
$this->PopulateObjectAttributes($row, $pog_object);
$objectList[] = $pog_object;
}
return $objectList;
}

Thanks for looking,
Tim
Reply all
Reply to author
Forward
0 new messages