Re: DataObject optimization
| From: | Alan | Date: | Tue, 22 Feb 2005 03:24:04 +0000 |
| Subject: | Re: DataObject optimization | ||
| References: | 1 | Groups: | php.pear.general php.pear.general |
| Request: | Send a blank email to pear-general+get-17616@lists.php.net to get a copy of this message | ||
On Mon, 2005-02-21 at 08:58 +0000, PHPDiscuss - PHP Newsgroups and
mailing lists wrote:
> Hi,
>
> Is it useful to delete dataobject (if we want more performance) with $do =
> null or unset($do) ?
> Is it depending on the instanciate method : factory or new ? What's the
> best way ? Does it cost a lot ?
$do->free(); can help (espeically if you are doing alot of inserts)
* should free the resultset, if it hasnt happened automatically.
* clears the insertid() cache in DB.
unsetting does help as well, basically you are freeing data from php.
>
> Another thing, here is a code example :
>
> $do = new DataObject_foo;
> while ($do->fetch()) {
>
> $do2 = new DataObject_foo2;
> $do2->find();
> while ($do2->fetch()) {
> //...
> }
> }
>
> the code above works differently :
>
> $do = new DataObject_foo;
> //i instanciate before loops
> $do2 = new DataObject_foo2;
> while ($do->fetch()) {
>
> $do2->find();
> while ($do2->fetch()) {
> //...
> }
> }
>
> any method with the $do2 object works only on the first cycle of the first
> loop but i don't understand why ?
calling find() twice on the same object results in extremely
unpredictable behavour. - just dont do it ;)
Regards
Alan
>
> Thx !
>
> JP Dumont