2011-08-08 37 views
0

如何使与Zend_SelectZend_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; 

回答

3

你必须标记静态值,使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' 
    ) 
); 
+0

谢谢,工作正常 –