For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2005 > Re: [PEAR] toArray was DB_DataObjects and generating search filters









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] toArray was DB_DataObjects and generating search filters
Laszlo Hermann

2005-04-25, 8:57 am

Yes, you're right; this was quite a bad example. I agree that the way is
building the DO, then find() and fetching() it. As for the huge DO array, as
you said, sometimes useful but this is a lot nicer:

while ($this->fetch()) {
$list[] = $this->toArray();
}






On 4/22/05, Justin Patrin <papercrane@gmail.com> wrote:
> On 4/21/05, Laszlo Hermann <laszlo.hermann@gmail.com> wrote:
>
> This is basically no different than:
>
> $smartyRenderer->setAttribute('persons', $db->getAll($query));
>
> The only thing you're really gaining here (unless you're using the DO
> for more than data storage in yoru Smarty Template which I hope you're
> not) is the ability to override fetch() to do data manipulation and
> such.
>
> In other words, you're *not really using DB_DataObject here*. You're
> using it as a wrapper for DB which basically just slows you down.
>
> 1) You're not supposed to write SQL with DB_DO. You *may* have to
> write snippets and whereAdd or selectAdd, but you shouldn't be writing
> the whole SQL.
> 2) You're meant to use the DB_DO data as you're fetching it. Making
> one huge array of DOs is useful sometimes, but in general is just
> going to use up lots of memory.
> 3) If all you're doing is fetching a bunch of records and making them
> into arrays you might as well be using DB directly. You're just
> including extra overhead by makign DB_DO do what DB already does.
>
array[color=darkred]
keys[color=darkred]
>
> --
> Justin Patrin
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com