Friday, October 12, 2007

PEAR MDB2 get array rows

This tip is for those who use PEAR MDB2 as your database abstraction layer. There are two nice methods, that are not in documentation, queryRow($query) and queryAll($query).

queryRow($query) - returns an associative array for one record
queryAll($query) - return an associative array for all found records

So for those who like to use arrays (like myself) you don't have to use fetchRow() anymore.

Documentation for this class can be found here.

1 comment:

JPatagonico said...

Thanks!
I change fetchrows for fetchall in my aplication and work fine.