Zend Framework

JOIN requires FROM otherwise it acts just like FROM

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.0RC1
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Db_Table
  • Labels:
    None
  • Fix Version Priority:
    Must Have

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/zend.db.table.html#zend.db.table.qry.rows.set.integrity.example

Issue Links

Activity

Hide
Stephen Crosby added a comment -

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', 'tableA.id=tableB.id');
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', 'tableA.id=tableB.id')
->joinLeft('tableB', 'tableA.id=tableB.id');

Show
Stephen Crosby added a comment - 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', 'tableA.id=tableB.id'); 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', 'tableA.id=tableB.id') ->joinLeft('tableB', 'tableA.id=tableB.id');
Hide
Wil Sinclair added a comment -

Please categorize/fix as needed.

Show
Wil Sinclair added a comment - Please categorize/fix as needed.
Hide
Simon Rupf added a comment -

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

Show
Simon Rupf added a comment - 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();
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - This issue has gone unaddressed for too long. I'm reassigning this to Ralph for re-evaluation and categorization.
Hide
Ralph Schindler added a comment -

Will evaluate within 2 weeks

Show
Ralph Schindler added a comment - Will evaluate within 2 weeks
Hide
Ralph Schindler added a comment -

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)

Show
Ralph Schindler added a comment - 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)
Hide
Ralph Schindler added a comment -

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.

Show
Ralph Schindler added a comment - 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.
Hide
Phil Brown added a comment -

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.

Show
Phil Brown added a comment - 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.
Hide
Ralph Schindler added a comment -

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

Show
Ralph Schindler added a comment - Changing the fix version - since this is a new feature it will be in 1.9

People

Vote (7)
Watch (7)

Dates

  • Due:
    Created:
    Updated:
    Resolved: