如何获取zend中每行的2列总和。我的代码是 -
$fieldArray = array('Jan','Feb', 'total'=>'Jan+Feb');
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()
->from($this->_name,$fieldArray);
die($select);
但它打印查询 -
选择Customer
。Jan
,Customer
。Feb
,Customer
。Jan+Feb
AS total
FROM Customer
它给出了错误。
如何编写语句以获得结果?
答案 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