I'm trying to write a simple database wrapper class. I've written a method like so:
public function get_objects($sql, $class_name = null) {
$result = mysql_query( $sql, $this->connection );
$objs = array();
if( $result ) {
while ($obj = mysql_fetch_object($result, $class_name)) {
$objs[] = $obj;
}
mysql_free_result($result);
}
return $objs;
}
If I don't specify $class_name when calling this method the call to mysql_fetch_object fails with the following error:
PHP Fatal error: Class '' not found in ...
The problem is I don't want it to use a class_name. I just want it to perform the default behavior as if I hadn't specified a class_name.
Why is this failing?