| 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
>
|