当使用从 Zend_Db_Table_Row_Abstract 继承的类时,如何连接 Zend 中的表?
我有一个扩展 Zend_Db_Table 的类,我们将其称为“Users”,它使用类“User”(继承自 Zend_Db_Table_Row_Abstract)作为其 rowClass。我需要这种方式,因为用户有我使用的其他方法。
据我所知,不可能在我的 Users 类中连接表,所以我使用:
$query = $db->select(); $query->from(...); $query->joinInner(...);
而不是
$this->select(); ...
但是当然我得到的行不属于 User 类。所以我想知道如何强制我的查询返回 User 对象而不是 Row 对象。
另一种方法是让 Zend_Db_Table 进行连接,在这种情况下我也会得到我想要的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用 David Caunt 在链接副本中的回答:
Quoting David Caunt's answer in linked duplicate: