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


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


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

Please categorize/fix as needed.

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();

This issue has gone unaddressed for too long. I'm reassigning this to Ralph for re-evaluation and categorization.

Will evaluate within 2 weeks

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)

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.

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.

 * 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.

Changing the fix version - since this is a new feature it will be in 1.9