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

joinAdd cannot join to non DB_DataObject table

Details

Submitted2005-02-24 00:52 UTC
Fromcraiga at webelements dot com dot au
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version5.0.2
OSirrelavent
Roadmaps(Not assigned)

Comments

[2005-02-24 00:52 UTC] craiga at webelements dot com dot au

Description:
------------
When calling the joinAdd function, and passing through as associative array as the $obj parameter, the join will only work if the target table has a proper DB_DataObject table class created. If not, the DB_DataObject::factory function returns a DB_DataObject_Error object.

The code handling this checks for a NULL result, but not for an error result. If this check is changed to also check for an error object, then the code works as advertised.

Reproduce code:
---------------
Changing line 2670 (in v1.7.2) from:
if (!$obj) {

to:

if (!$obj || PEAR::isError($obj)) {

Fixes the problem.

Expected result:
----------------
The join should occur, and the object performing the join should end up with a data member for each column in the table being joined to.

Actual result:
--------------
Fatal error, as joinAdd function attempts to use $obj as a DB_DataObject (and call table() on it), when in fact it is an error object.