zend 数据库相交
Zend_Db_Select 对象是否支持 Intersect?。它支持联合(即这是可能的, $db->select->union($sql1,$sql2) ),但是当我查看文档时,没有像 intersect 这样的方法。
那么还有什么办法可以与 Zend_Db 相交呢?
Does Zend_Db_Select object support Intersect?. It supports union (i.e this is possible, $db->select->union($sql1,$sql2) ), but when I look at the documentation, there is no method like intersect.
So How else is intersection possible with Zend_Db?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管我不想这么说,但
Zend_Db_Select
不支持INTERSECT
的任何内容。你必须发挥你的聪明才智才能使这一切成为可能。您可以扩展Zend_Db_Select
以添加该功能或构建 SQL 字符串并使用适配器来获取记录。通过扩展
Zend_Db_Select
来完成以下任务应该不会太难。为了实现这一点,在通过
My_Db_Select::intersect< 添加对象时,您必须为相交对象创建一个存储。 /code> 然后创建
My_Db_Select::assemble
以首先调用$sql =parent::assemble
然后循环遍历相交部分并将每个调用附加到每个上组装
。 foreach($intersect as $select) $sql .= ' INTERSECT ' 。 $select->assemble();As much as I don't want to say this, but
Zend_Db_Select
does not support anything withINTERSECT
. You will have to use your ingenuity to make this possible. You can extendZend_Db_Select
to add that functionality or build your SQL string and use the Adapter to fetch the records.It shouldn't be too hard to accomplish the following by extending
Zend_Db_Select
In order to accomplish that, you will have to create a storage for your intersect objects when adding objects via
My_Db_Select::intersect
and then createMy_Db_Select::assemble
to first call$sql = parent::assemble
and then loop through the intersect parts and append each call toassemble
on each.foreach($intersect as $select) $sql .= ' INTERSECT ' . $select->assemble();