2011-08-08 79 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

謝謝,工作正常 –