ZF-2798: JOIN requires FROM otherwise it acts just like FROM

Issue Type: Bug Created: 2008-03-04T04:26:47.000+0000 Last Updated: 2009-07-08T07:29:18.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Dimitri van Hees (s481797) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db_Table

Related issues: - ZF-2546



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:…


Posted by Stephen Crosby (stevecrozz) on 2008-03-04T17:33:30.000+0000

Steps to reproduce:

  1. Create a table class for a database table that extends Zend_Db_Table_Abstract
  2. Create an accessor function that uses: $select = $this->select() ->setIntegrityCheck(false) ->joinLeft('tableB', ''); echo $select->__toString();

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', '') ->joinLeft('tableB', '');

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', ''); 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.

<pre class="highlight">
 * Returns an instance of a Zend_Db_Table_Select object.
 * @return Zend_Db_Table_Select
public function select()
    require_once 'Zend/Db/Table/Select.php';
    return new Zend_Db_Table_Select($this);

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

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.