Hi Simon,
> protected function _fetch(Zend_Db_Table_Select $select)
> {
> // extend select
> $select->setIntegrityCheck(false);
> $select = $this->_extendSelect($select);
> .....
Thanks again, this solves this issue but rises the next exception:
Zend_Db_Statement_Exception: SQLSTATE[42S22]: Column not found:
1054 Unknown column 'right_module' in 'where clause'
And now it is really getting weird. In my extending class for debugging
I added just two echos to see what is going on:
-------------------------------------------------------------------
class Member_Model_Right extends Travello_Db_Table
{
protected $_name = 'member_right';
protected $_primary = 'right_id';
protected function _extendSelect(Zend_Db_Table_Select $select)
{
echo $select . "\n";
// add join for member role
$select->joinLeft('member_role', 'right_role_id = role_id',
array('role_name', 'role_identifier'));
echo $select . "\n";
// return select object
return $select;
}
}
-------------------------------------------------------------------
With these two echoes the mentioned exception above is not thrown any more.
Then I deleted these echoes and added another echo to
Zend_Db_Table_Select::__toString() in the first line:
-------------------------------------------------------------------
class Zend_Db_Table_Select extends Zend_Db_Select
{
public function __toString()
{
echo parent::__toString();
...
}
}
-------------------------------------------------------------------
The printout shows the wrong build of the select. It seems as if the
setting for the FROM table and the COLUMNS are overwritten by my
joinLeft() call.
-------------------------------------------------------------------
SELECT
`member_role`.`role_name`,
`member_role`.`role_identifier`
FROM `member_role`
WHERE
(right_module LIKE '%article%')
ORDER BY
`right_mode` ASC
-------------------------------------------------------------------
After the joinLeft() method call in Member_Model_Right::extendSelect()
it should rather print out this:
-------------------------------------------------------------------
SELECT
`member_right`.*,
`member_role`.`role_name`,
`member_role`.`role_identifier`
FROM `member_right`
LEFT JOIN `member_role` ON right_role_id = role_id
WHERE
(right_module LIKE '%article%')
ORDER BY
`right_mode` ASC
-------------------------------------------------------------------
So the addition of a LEFT JOIN to Zend_Db_Table_Select seems not be
working.
And finally here is my quick hack to get the whole lot running again
now. I just added another line to my Travello_Db_Table::_fetch() method:
-------------------------------------------------------------------
abstract class Travello_Db_Table extends Zend_Db_Table_Abstract
{
protected function _fetch(Zend_Db_Table_Select $select)
{
// hack to get the select building working again
$dummy = $select->__toString();
// extend select
$select->setIntegrityCheck(false);
$select = $this->_extendSelect($select);
// return the results
$stmt = $this->_db->query($select);
$data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
return $data;
}
}
-------------------------------------------------------------------
After adding this one line my whole application seems to be working
again. Does this help you to track down the problems I encountered? How
can it be that a simple call to Zend_Db_Table_Select::__toString()
before the call of Zend_Db_Table_Select::joinLeft() fixes this weird issue?
Thanks again and Best Regards,
Ralf