Thanks for the reply. It seems like using count() is the only way to test
for empty rowsets.

The question is more about iterators in general, since they can (almost) be
drop-in replacements for arrays.

I'm OK with using count(). I was just curious if it's possible to make an
object work with empty() and get expected results. Most of the developers on
my team have been used to using empty() with arrays and it can be confusing
why empty() won't work on a rowset. Maybe PHP needs a built-in IsEmpty
interface? :)

--
Hector


On Thu, Oct 29, 2009 at 10:07 AM, prodigitalson <ant.cunning...@gmail.com>wrote:

>
>
> Hector Virgen wrote:
> >
> > Calling empty() on a rowset (Zend_Db_Table_Rowset) always returns false,
> > even if the rowset has zero rows. Is there a way to make rowsets (or any
> > iterator) work with empty()? Or is !count($rowset) the only way to test
> > for
> > an empty rowset?
> >
>
> You need to use count() or you could use the $rowset->count() method
> directly. In the case of the Rowset class the "count" of returned rows is
> held directly in a property so youre not iterating through each time its
> called to get the value its simply returning.
>
> If you actually need a boolean value you can cast it or you could extend
> rowset and implemnt a method to do this and then call that.
>
> Is there a particular reason you wanted to use empty (aside from
> traditional
> count/empty performance)?
> --
> View this message in context:
> http://www.nabble.com/Rowsets-and-empty%28%29-tp26116340p26117087.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>

Reply via email to