How to check if Zend returns a result or not

As part of Zend, how do I check if a zend_db_selectresult returns or not?

$result = $this->fetchAll();

there is a better way than using:

if(count($result) != 0){
    //result found!
}
+5
source share
4 answers
$rows = $this->fetchAll();
return (!empty($rows)) ? $rows : null;
+9
source

I like to use classics:

   //most of these queries return either an object (Rowset or Row) or FALSE 
   if (!$result){
        //do some stuff
    } else {
        return $result;
    }
+6
source

I found this method and worked fine for me:

if($result->count() > 0) {
    //Do something
}

Thanks Åsmund !

+2
source

The method returns NULL, not FALSE. Verify this value using the if condition.

+1
source

All Articles