Zend_Select选择静态值

时间:2011-08-08 11:29:54

标签: zend-framework

如何使用Zend_Select

发出请求
SELECT "subdivision" as `type`, a.id as id FROM `some_table` a;

这样做

$ this-> select ()
-> from (
        array ('a' => 'some_table'), array ('type' => "subdivision", 'id' => 'a.id')
)

结果

SELECT `a`. `" Subdivision "` as `type`, a.id as id FROM `some_table` a;

1 个答案:

答案 0 :(得分:4)

您必须标记静态值,以便Zend_Db_Select不会使用Zend_Db_Expr将该值作为标识符引用。

$this->select()
     ->from(array(
         'a' => 'some_table'
     ), array(
         'type' => new Zend_Db_Expr($db->quote('subdivision')), 
         'id'   => 'a.id'
     )
);