【发布时间】:2014-08-22 11:58:13
【问题描述】:
这是我需要从 zend ORM 生成的 SQL。它作为sql工作,但我需要从zend2 ORM重新创建它,当我获取'type'列的数据时,如果数据来自table1,它应该检索'type1',当它来自table2时,它应该是'type2'。
select id,'type1' as type
from table1
UNION
select id,'type2' as type
from table2 where id = 1
我在 zend2 中使用过类似的东西,但没有给我正确的值。
$select->from(array('a' => 'table1'));
$select->columns(array(
"id",
"'type1'" => "type"
));
$select2->from(array('t2' => 'table2'));
$select2->columns(array(
"id",
"'type2'" => "type"
));
$select->combine ( $select2 );
【问题讨论】:
标签: php zend-framework orm zend-framework2