Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.0
-
Fix Version/s: 1.8.2
-
Component/s: Zend_Db_Select, Zend_Db_Table
-
Labels:None
-
Fix Version Priority:Should Have
Description
The functionality described in example 10.96 in the reference guide does not work.
The code:
<?php
$table = new Bugs();
$select = $table->select();
$select->where('bug_status = ?', 'NEW')
->join('accounts', 'accounts.account_id = bugs.reported_by')
->where('accounts.account_name = ?', 'Bob');
$rows = $table->fetchAll($select);
Results in a simple select * from the accounts table where account_name = "Bob", the join is ignored.
A possible workaround is to use an explicit ->from() call on the select object. Like this:
$select->from('bugs');
The query is now correctly formatted as a join query but it selects all columns from both bugs and accounts. This seems like a reasonable default behavior for the select object, but in the above usage it is required that only columns from bugs is returned to create a writable row object. The ->setIntegrityCheck(false) method to allow creation of read only rows with columns from both tables, but this is not the very useful behavior described in the reference guide.
Possible solution:
- Make the select object returned from a table object contain a from part by default.
- Alter the documentation-code so that no columns are added from the joined table (how is this is done?)
Issue Links
| This issue depends on: | ||||
| ZF-2546 | Zend_Db_Table_Select should include its own table in the FROM section |
|
|
|
Please categorize/fix as needed.