Zend框架选择对象和UNION() [英] Zend Framework Select Objects And UNION()

查看:74
本文介绍了Zend框架选择对象和UNION()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定,在Zend Framework中这是不可能的(我已经搜索过Web,文档和问题跟踪器),但我只是想确定一下,所以我要在这里询问.

I'm pretty sure this is not possible in Zend Framework (I have searched the Web, the documentation and issue tracker) but I just want to make sure so I'm asking here.

$select = $this->select();
$select->union($select1, $select2);

那当然是行不通的.解释一下我需要什么.我需要使用UNION()在SELECT查询中合并2个表,我知道我可以做到:

That doesn't work of course. To explain what I need. I need to use UNION() to merge 2 tables in a SELECT query, I know I could just do:

$select = "$select1 UNION $select2";

问题是返回一个字符串,我需要获取一个选择对象,以便可以与Zend_Paginator一起使用.

The problem is that would return a string and I need to get a select object so I can use it with Zend_Paginator.

我已经通过修改数据库体系结构解决了该问题,但我只是想知道是否有解决方法.

I have already solved the issue by modifying my database architecture but I'm just curious if there is some workaround for this.

推荐答案

Zend_Db_Select

Zend_Db_Select has a union method so I'd have thought it is possible, if you can build your query using a select object. I haven't used Zend_Db_Select (or the table subclass) with union but I'd imagine you can do something like

$select = $this->select()
               ->where('blah')
               ->union($sql);

这篇关于Zend框架选择对象和UNION()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆