PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #9938

Thanks!

Details

Request #9938Thanks!
Submitted2007-01-25 04:56 UTC
Fromjeremytsilva at yahoo dot com
StatusWont fix
PackageDB_DataObject
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2007-01-25 04:56 UTC] jeremytsilva at yahoo dot com

Description:
------------
It would be nice to have a "Reset" function for the parent DB_dataobject class, to completely clear all settings for the object.

This would allow DB object re-use.

Test script:
---------------
In my auto-generated extended objects, I have used the following to create a "pseudo-reset" that completely clears all the relevant search settings for an object. Its probably not the most efficient function, but works for all intensive purposes.

function reset(){
$subvars[]="";
//collect subs to ignore in our reset.
foreach (get_class_vars(get_parent_class($this)) as $key=>$value) $subvars[]=$key;
foreach (get_class_vars($this) as $key=>$value)
if (!in_array($key,$subvars)) $this->$key=null;
$this->_query['condition']="";
}

[2007-01-25 05:03 UTC] jeremytsilva at yahoo dot com

Sorry, the code should be:

function reset(){
$subvars[]="";
//collect subs to ignore in our reset.
foreach (get_class_vars(get_parent_class($this)) as $key=>$value) $subvars[]=$key;
foreach (get_class_vars(get_class($this)) as $key=>$value)
if (!in_array($key,$subvars)) $this->$key=null;
$this->_query['condition']="";
}

[2007-01-26 02:45 UTC] jeremytsilva at yahoo dot com

I'm curious though, do you incur any significant overhead of using clone versus simply reusing the same db object? In your first example, don't you essentially create 3 separate objects ?

[2007-02-07 01:58 UTC] jeremytsilva at yahoo dot com

Thanks Alan! Appreciate the time you took setting me straight!