How can I join tables in Zend while using a class that inherits from Zend_Db_Table_Row_Abstract?

空扰寡人 提交于 2019-12-12 17:19:28

问题


I have a class that extends Zend_Db_Table lets call it 'Users' that uses the class 'User' (inheriting from Zend_Db_Table_Row_Abstract) as its rowClass. I need it this way because User has additional methods that I use.

As far as I know it is not possible to join tables inside my Users class so I use:

$query = $db->select(); $query->from(...); $query->joinInner(...);

instead of

$this->select(); ...

But then of course the rows I get are not of the User class. So I would like to know how can I force my query to return User objects instead of Row objects.

Another way would be to get Zend_Db_Table to make that join in which case I would also get what I want.


回答1:


Quoting David Caunt's answer in linked duplicate:

Because Zend_Db_Table provides row gateway functions, which don't work if you join on other tables, you have to state that you are willing to give it up. Simply make a call to setIntegrityCheck and it will work:

$select->setIntegrityCheck(false);



来源:https://stackoverflow.com/questions/3255466/how-can-i-join-tables-in-zend-while-using-a-class-that-inherits-from-zend-db-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!