PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_Table » Bug #3017

[PATCH[ selectCount()

Details

Request #3017[PATCH[ selectCount()
Submitted2004-12-22 21:03 UTC
Fromieure at php dot net
Assignedpmjones
StatusClosed
PackageDB_Table
PHP Version4.3.9
OSLinux
Roadmaps(Not assigned)

Comments

[2004-12-22 21:03 UTC] ieure at php dot net

Description:
------------
I mentioned this in an email a couple days ago; here's the
patch.

This implements a selectCount() method, which works
exactly the same as select(), but returns the number of
rows that select() will return for the identical query.

I implemented this so I could minimize DB traffic when
using DB_Table with Pager. Pager either needs the full set
of data you want to display, or the total number of items
in the dataset. Selecting everything from a big table and
passing it to Pager is impractical and ineffecient. The
same applies to selecting everything from the table and
passing count($res) to Pager. Likewise, it seems silly to
create seperate 'countFoo' queries in DB_Table for every
query you may possibly want to get counts for.

This solves the problem by autocreating queries to return
the count for a 'real' query.

Patch is against current CVS:
http://atomized.org/PEAR/Patches/DB_Table-selectCount.patch