PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #3540

Connection caching

Details

Submitted2005-02-21 09:46 UTC
Fromfela at ds dot pg dot gda dot pl
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version5.0.0
OSLinux
Roadmaps(Not assigned)

Comments

[2005-02-21 09:46 UTC] fela at ds dot pg dot gda dot pl

Description:
------------
I've found some bug with caching connection. It appears if you first call free() method of some object and try to call insert() with other object.

Reproduce code:
---------------
$obj = new DB_DataObjects;
$obj->free();
$obj = new DB_DataObjects;
$obj->name = 'Smith';
$obj->insert();

IMO it is bug at the end of free() method because there is creating connection as stdClass object.

// this is a huge bug in DB!
$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->num_rows = array();

and in insert() method this object is using to executing query.

Expected result:
----------------
I think is good to check before this if connection is set:

// this is a huge bug in DB!
if (isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {

$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->num_rows = array();

}