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?
How else can I check if it is a string or an mysqli_result?
if (is_string($result)) {
// Result is a string
}
if ($result instanceof mysqli_result) {
// Result is a mysqli_result object
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With