Jump to content
Larry Ullman's Book Forums

Retrieving Results Using Ar Find And Findall

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...