This is my code:
public function is_existing($url) {
$query = $this->select()
->where("url=?",$url);
if(!$query) {
return false;
} else {
$row = $this->fetchRow($query);
$row = $row->toArray();
return $row;
}
}
But sometimes, I receive
Fatal error: Call to a member function toArray() on a non-object in…
Is it right to use if(!$query) to check the existing rows in DB?
Change your code to this
Because $query object will always be created irrespective $url matches record or not hence will always pass if condition .