If I do something like :
$result = mysql_query($query);
$dbArray = dbResultIntoKeyArray($result);
and this is the function:
function dbResultIntoKeyArray($result) {
while ($row = mysql_fetch_object($result, MYSQL_ASSOC)) {
$dbArray[] = $row;
}
return $dbArray;
}
then if the query came back empty I get an error message: not a valid
mysql resource.
What is the correct way of handling this? If I was dealing with an
array I'd start the function with something like:
if (is_array($array)) {
}
and then I wouldn't have to worry about error messages if it turned
the variable wasn't an array. What is the similar test for database
returns?