use*_*421 0 php zend-framework
我如何UNION ALL在Zend Framework中以这种方式使用?
(select id from astrology where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017') union all
(select id from facereading where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017') union all
(select id from numerology where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017') union all
(select id from palmistry where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017') union all
(select id from solutions where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017') union all
(select id from vastu where commu_time_from <= '11:51' and commu_time_to >= '11:51' and user_id=1 and appo_date='03/01/2017')
Run Code Online (Sandbox Code Playgroud)
我还需要弄清楚如何跟踪结果中的总行数.
小智 6
您需要将一个数组传递Zend_Db_Select给union()方法.要传递union()给执行UNION类型的方法的第二个参数.在您的情况下,使用 Zend_Db_Select::SQL_UNION_ALL作为常量.
例如
$sql1 = $db->select();
$sql2 = "SELECT ...";
$select = $db->select()
->union(array($sql1, $sql2), Zend_Db_Select::SQL_UNION_ALL );
Run Code Online (Sandbox Code Playgroud)
参考:http: //framework.zend.com/manual/1.12/en/zend.db.select.html#zend.db.select.building.union
| 归档时间: |
|
| 查看次数: |
4425 次 |
| 最近记录: |