PEAR is archived and read-only

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

Home » Database » DB_QueryTool » Bug #2133

DB_QueryTool_Query::addLeftJoin(), bugs if none left join was previously set

Details

Submitted2004-08-16 15:11 UTC
Fromjulien dot huang at netavenir dot fr
Assignedquipo
StatusClosed
PackageDB_QueryTool
PHP VersionIrrelevant
OSAll
Roadmaps(Not assigned)

Comments

[2004-08-16 15:11 UTC] julien dot huang at netavenir dot fr

Description:
------------
Package: DB_QueryTool v0.10.1
File: DB/Query.php v1.47

If you don't set a left join and call the addLeftJoin method, the where array ($this->_join[$type]['where']) will be "corrupted".

Because firstly $this->_join[$type]['where'] is an empty string, and during addLeftJoin call, $this->_join[$type]['where'] is transtyped into an array().

Then the method append a new value to the array. Result: the where array contains two entries, an empty string and a where condition whereas it should contain only a single entry.

Reproduce code:
---------------
DB/Query.php [line 1099]

Replace:
if (!is_array($this->_join[$type]['where'])) {
settype($this->_join[$type]['where'], 'array');
}

By:
if (!is_array($this->_join[$type]['where'])) {
if (!empty($this->_join[$type]['where']))
settype($this->_join[$type]['where'], 'array');
else
$this->_join[$type]['where'] = array();
}

[2004-08-16 15:13 UTC] julien dot huang at netavenir dot fr

The concerned file isnt DB/Query.php, but DB/QueryTool/Query.php.

Sorry for the mistake.