Hi Andi,
it took me already half the day to track it down to this current
problem. I already fixed other issues but whenever I fix one issue the
next problem occurs.
Basically, I implemented a feature to add some joins without using the
Zend_Db_Table relationship feature, simple because this feature did not
exist when I started to extend Zend_Db_Table. I extend the _fetch()
method to add the joins:
-------------------------------------------------------------------
abstract class Travello_Db_Table extends Zend_Db_Table_Abstract
{
protected function _fetch(Zend_Db_Table_Select $select)
{
// extend select
$select = $this->_extendSelect($select);
// return the results
$stmt = $this->_db->query($select);
$data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
return $data;
}
protected function _extendSelect(Zend_Db_Table_Select $select)
{
// return select object
return $select;
}
}
-------------------------------------------------------------------
Here is an example for one class that extends Travello_Db_Table
-------------------------------------------------------------------
class Member_Model_Right extends Travello_Db_Table
{
protected $_name = 'member_right';
protected $_primary = 'right_id';
protected function _extendSelect(Zend_Db_Table_Select $select)
{
// add join for member role
$select->joinLeft('member_role', 'right_role_id = role_id',
array('role_name', 'role_identifier'));
// return select object
return $select;
}
}
-------------------------------------------------------------------
Currently, I get this exception "Zend_Db_Table_Select_Exception: Select
query cannot join with another table". Since Zend_Db_Table_Select is
hardcoded throughout the Zend_Db_Table I have no idea how to work around
this.
So at the moment I think I need to rework my Travello_Db_Table to use
the build-in relationship Zend_Db_Table feature rather than my own. But
I am not sure if the build-in Zend_Db_Table relationship feature works
the way I expect it to, i.e. join tables for each find(), fetchRow() or
fetchAll() method call.
Thanks for any help or advise.
Best Regards,
Ralf