2008年12月9日星期二

[fw-db] Adding a join clause to a Zend_Db_Table_Abstract select method has unexpected results

class Methods extends Zend_Db_Table_Abstract {
function filterByMoaAndSpecies($moaID, $speciesID) {
$select = $this->select();
$select->join('species_methods', 'species_methods.method_id = methods.id',
array());

print_r($select->__toString());
}

The above code produces the following:
SELECT `Methods`.* FROM `species_methods` INNER JOIN `Methods`

I expected it to produce:
SELECT `Methods`.* FROM `Methods` INNER JOIN `species_methods`

Why is it not so? If I remove the third parameter from the join method, the
empty array, or if I try to pass an array of column names, it produces the
error:
PHP Warning: Select query cannot join with another table in
C:\PHP\includes\Zend\Db\Select.php on line 1222

It also produces the above error if I try to specify another join clause, or
a from('methods') clause.

Many thanks.
--
View this message in context: http://www.nabble.com/Adding-a-join-clause-to-a-Zend_Db_Table_Abstract-select-method-has-unexpected-results-tp20918489p20918489.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: