Issue Details (XML | Word | Printable)

Key: ZF-2798
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Ralph Schindler
Reporter: Dimitri van Hees
Votes: 7
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

JOIN requires FROM otherwise it acts just like FROM

Created: 04/Mar/08 04:26 AM   Updated: 08/Jul/09 07:29 AM  Due: 23/Jan/09   Resolved: 18/May/09 03:15 PM
Return to search "Fixed in 1.5.1"
Component/s: Zend_Db_Table
Affects Version/s: 1.5.0RC1
Fix Version/s: 1.9.0

Time Tracking:
Not Specified

Issue Links:
Dependency
 

Fix Version Priority: Must Have


 Description  « Hide

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



Stephen Crosby added a comment - 04/Mar/08 05:33 PM

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


Wil Sinclair added a comment - 25/Mar/08 08:43 PM

Please categorize/fix as needed.


Simon Rupf added a comment - 28/Jul/08 10:47 PM

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


Wil Sinclair added a comment - 06/Jan/09 10:57 AM

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


Ralph Schindler added a comment - 10/Jan/09 11:25 AM

Will evaluate within 2 weeks


Ralph Schindler added a comment - 18/May/09 03:15 PM

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)


Ralph Schindler added a comment - 19/May/09 06:27 AM

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.


Phil Brown added a comment - 07/Jul/09 09:10 PM

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.


Ralph Schindler added a comment - 08/Jul/09 07:29 AM

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