zend中每行的2列之和

时间:2013-10-25 05:29:14

标签: php mysql sql zend-framework

如何获取zend中每行的2列总和。我的代码是 -

$fieldArray = array('Jan','Feb', 'total'=>'Jan+Feb');
$db = Zend_Db_Table::getDefaultAdapter();

$select = $db->select()
->from($this->_name,$fieldArray);
    die($select);

但它打印查询 -
选择CustomerJanCustomerFebCustomerJan+Feb AS total FROM Customer 它给出了错误。

如何编写语句以获得结果?

2 个答案:

答案 0 :(得分:1)

你可以试试这个:

$fieldArray = array('Jan','Feb', 'total'=>new Zend_Db_Expr('Jan+Feb'));
$db = Zend_Db_Table::getDefaultAdapter();

$select = $db->select()
->from($this->_name,$fieldArray);
    die($select);

答案 1 :(得分:0)

查询应该像

SELECT Customer.Jan,Customer.Feb,Customer.Jan + Customer.Feb AS FROM FROM Customer