Re: DB_DataObject
| From: | Justin Patrin | Date: | Thu, 21 Sep 2006 21:50:38 +0000 |
| Subject: | Re: DB_DataObject | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25194@lists.php.net to get a copy of this message | ||
On 9/21/06, Chris Boget <chris.boget@wild.net> wrote:
I'm having a problem using it to get all the records from the table. I've got a class, Users, that extends DB_DataObject (generated using createTables.php). If I just want to get a subset, this works perfectly fine: $users = new Users(); $users->country = 'USA'; $users->find(); Ok, so now I just want to get all the users. So after reading the DB_Object documentation (and the source code), the closest I was able to determine how to do this is as follows: $users = new Users() $users->selectAdd('*') You don't need that.
//$users->find(); // Actually, I'm not even sure this is needed Of course you need this. It's how the query is run.
So the only change in my code is to use selectAdd() instead. If I make that change, I get an error message saying: "DB_DataObject Error: No database name / dsn found anywhere" Why am I getting that? Everything worked fine enough for the first example. Also, am I doing the right thing to get all the records in the table?$do = DB_DataObject::factory('table'); if ($do->find()) { while ($do->fetch()) { echo $do->field."\n"; } } -- Justin Patrin