Zend Db 表抽象操作 select()
是否有机会在有关 Zend Db 表抽象对象的任何 select() 请求上设置 where 语句?
示例: 我们有 2 个角色,1 个角色“管理员”可以查看所有产品,1 个角色“供应商”只能查看自己的产品。
我不想检查角色并设置位置每个 ActionController 中的 Zend Db Table 抽象对象的语句。 Zend Db Table Abstract 中是否有机会执行此操作?
class ProductsModel extends Zend_Db_Table_Abstract
{
protected $_name = 'artikel';
protected $_primary = 'ID';
protected $_where = ('supplier = ?', $this->_auth->Role ); # SOMETHING LIKE THAT ??
}
谢谢! M。
is there any chance to set a where statement on any select() request regarding a Zend Db Table Abstract Object?
Example:
We have 2 roles, 1 role 'admin' which is allowed to see all products and 1 role 'supplier' which is allowed to see only their own products.
I don't want to check the role and set the where statement for the Zend Db Table Abstract Object in every ActionController. Is there any chance to do this in the Zend Db Table Abstract?
class ProductsModel extends Zend_Db_Table_Abstract
{
protected $_name = 'artikel';
protected $_primary = 'ID';
protected $_where = ('supplier = ?', $this->_auth->Role ); # SOMETHING LIKE THAT ??
}
Thanks!
M.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ZF中有两种定义:模型和表。你不应该替代它们。该模型描述了Controller和Table之间的抽象层。该模型可以通过 Mapper 与 Table 配合使用,您可以在其中实现所有业务逻辑(where 子句、顺序、限制等)。
所有这些都包含在标准 ZF 示例模板中。
There are two definitions in ZF: Model and Table. You should not substitute them. The model describes abstract layer between Controller and Table. The model may work with Table by means of Mapper where you can implement all business logic (where clauses, order, limit and so on).
It all are included into standart ZF example template.