I’m writing a database wrapper both in mysql and mysqli.
To get data via fetch_object() I’ve written a method:
public function fetch($mixed)
{
if (is_resource($mixed))
{
return mysql_fetch_object($mixed);
}
elseif (!empty($mixed))
{
$result = $this->query($mixed);
return mysql_fetch_object($result);
}
elseif (is_resource($this->result))
{
return mysql_fetch_object($this->result);
}
return false;
}
Now I’ve heard that is_resource() is not a good solution for mysqli.
How else can I check if it is a string or an mysqli_result?
1 Answer