Jump to content
Larry Ullman's Book Forums

Retrieving Results Using Ar Find And Findall


lrzins
 Share

Recommended Posts

Hi Larry, to determine if any records are returned using find() and findAll(), I see that when nothing is returned using find(), that a NULL is returned. When nothing is found using findAll that an empty array is returned.

 

Is this the best way to determine if records are returned?:

 

 

$var=SomeModelClass::model()->find($condition, $params);

if ($var !== null) 
    // Check if a single record is returned.

 

 

$var=SomeModelClass::model()->findAll($condition, $params);

if (!empty($var))
   // Check for returned records

 

Larry Z.

Link to comment
Share on other sites

 Share

×
×
  • Create New...