ZF-2798: JOIN requires FROM otherwise it acts just like FROM
Description
Joining tables with {{setIntegrityCheck(false)}} doesn't work without specifying the primary table with {{$select->from($table)}}. If {{from}} is not specified, {{join}} acts exactly the same as {{from}} and doesn't use it's required parameters at all.
More info about this: http://framework.zend.com/manual/en/…
Comments
Posted by Stephen Crosby (stevecrozz) on 2008-03-04T17:33:30.000+0000
Steps to reproduce:
reveals that the first table (the one for which the table class was extended) is not part of the query.
(ugly workaround, add another join to force the original table back into the query) $select = $this->select() ->setIntegrityCheck(false) ->joinLeft('tableA', 'tableA.id=tableB.id') ->joinLeft('tableB', 'tableA.id=tableB.id');
Posted by Wil Sinclair (wil) on 2008-03-25T20:43:58.000+0000
Please categorize/fix as needed.
Posted by Simon Rupf (simon.rupf) on 2008-07-28T22:47:30.000+0000
Found another workaround: Instead of the (ugly) join() on the table itself, just use the from().
$select = $this->select() $select->setIntegrityCheck(false); $select->from('tableA'); $select->joinLeft('tableB', 'tableA.id=tableB.id'); echo $select->__toString();
Posted by Wil Sinclair (wil) on 2009-01-06T10:57:42.000+0000
This issue has gone unaddressed for too long. I'm reassigning this to Ralph for re-evaluation and categorization.
Posted by Ralph Schindler (ralph) on 2009-01-10T11:25:14.000+0000
Will evaluate within 2 weeks
Posted by Ralph Schindler (ralph) on 2009-05-18T15:15:56.000+0000
Fixed in r15632, still need to determine if this is a mini or minor release point feature (this is a new feature, not a bug as the issuer claims since the select object indeed did work as originally designed)
Posted by Ralph Schindler (ralph) on 2009-05-19T06:27:20.000+0000
To be clear, the fix is that the a parameter ($withFromPart) was added to Zend_Db_Table_Abstract::select($withFromPart = false). To get an instance of the select object with the from loaded, simply call $table->select(true). This feature keeps backwards compatibility as well as provides a solution most people can work with if they need the select object preloaded.
Posted by Phil Brown (philbrown) on 2009-07-07T21:10:07.000+0000
I notice that this issue is marked as fixed in 1.8.2 but looking into Zend_Db_Table_Abstract 1.8.4, the fix appears to be missing.
The constant Zend_Db_Table_Abstract::SELECT_WITH_FROM_PART is also absent.
Posted by Ralph Schindler (ralph) on 2009-07-08T07:29:10.000+0000
Changing the fix version - since this is a new feature it will be in 1.9