Re: DB_DataObject custom fetch function
| From: | Justin Patrin | Date: | Wed, 18 Aug 2004 17:15:20 +0000 |
| Subject: | Re: DB_DataObject custom fetch function | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14161@lists.php.net to get a copy of this message | ||
On Wed, 18 Aug 2004 17:11:20 +0200 (MEST), Thomas Mammitzsch
<smartt@gmx.de> wrote:
> hi,
>
> i want to use a function like this, to fetch all rows
>
> function fetch_all($object)
> {
> $array=array();
> while($object->fetch())
> {
> $array[] = clone($object);
> }
> return $array;
> }
>
> whats the best place to define this function? I don't want to put it in
> every DataObject Class(the table specific ones).
> Maybe defining an own class extending the base DataObject Class and tell
> every Dataobject class to extend my class instead of the base class? how are
> you handling this?
>
Yes, this is the right answer. Put it all in your own class which
extends DB_DataObject, then have your DOs extends that one. You can
even set it in yout ini file and tell the generator to re-write the
extends section (with another ini setting).
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--