Zend_Db_Table and mysql COUNT() function

3 messages Options
Embed this post
Permalink
greg606

Zend_Db_Table and mysql COUNT() function

Reply Threaded More More options
Print post
Permalink
Hi
I have a table (Zend_Db_table object) and I want to count rows.
What is the simplest way to do it? ;)

Regards
Greg
Ralph Schindler-2

Re: Zend_Db_Table and mysql COUNT() function

Reply Threaded More More options
Print post
Permalink
What rows do you want to count?

If you get a rowset back, you can always call count:

$rowset = $table->fetchAll('foo = "bar"');

echo count($rowset);
// OR
echo $rowset->count();

Does that help? I feel you might have a more specific question, but that
basically is counting an existing rowset.

-ralph


greg606 wrote:
> Hi
> I have a table (Zend_Db_table object) and I want to count rows.
> What is the simplest way to do it? ;)
>
> Regards
> Greg
umpirsky

Re: Zend_Db_Table and mysql COUNT() function

Reply Threaded More More options
Print post
Permalink
Why fetching all rows if you need just count? It's far faster to select count (*).

Regards,
Saša Stamenković


On Wed, Oct 28, 2009 at 11:15 PM, Ralph Schindler <[hidden email]> wrote:
What rows do you want to count?

If you get a rowset back, you can always call count:

$rowset = $table->fetchAll('foo = "bar"');

echo count($rowset);
// OR
echo $rowset->count();

Does that help? I feel you might have a more specific question, but that basically is counting an existing rowset.

-ralph



greg606 wrote:
Hi
I have a table (Zend_Db_table object) and I want to count rows.
What is the simplest way to do it? ;)

Regards
Greg