Hi Ralf

By default an 'integrity check' is performed on the select object to prevent joins. But you can manually override this:-

   protected function _fetch(Zend_Db_Table_Select $select)
   {
       // extend select
       $select->setIntegrityCheck(false);
       $select = $this->_extendSelect($select);
        .....

This should get you back on track - it's not a documented feature, as creating hybrid rows doesn't truly represent the integrity of Zend_Db_Table. But if you do this, you will get a rowset/row that is read only (which I guess is what you want?).

Let me know how you get on.

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


--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "

202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com

Reply via email to