Reputation: 87
i have this db function in f3 framework
public function sumOfAmount($startdate, $enddate) {
$this->amount = 'price*quantity';
$this->sumamount = 'SUM(price*quantity)';
$this->load(array('createon > ? AND createon < ?', $startdate, $enddate));
//return $this->query;
return $this->cast();
}
it seem that sumamount is not correct , from the f3 log i have this query executed
SELECT `idproduct`,`idtransaction`,`idline`,`name`,`code`,`price`,`quantity`,`createon`,(price * quantity) AS `amount`,(SUM(price * quantity)) AS `sumamount` FROM `qrysales`
but if i run that query in phpmyadmin result is ok
Any idea??
Upvotes: 1
Views: 80
Reputation: 87
it seems that i forgot group by clause
public function sumOfAmount($startdate, $enddate) {
$this->amount = 'price*quantity';
$this->sumamount = 'SUM(price*quantity)';
$this->load(array('createon > ? AND createon < ?', $startdate, $enddate,'group' => 'idline'));
//return $this->query;
return $this->cast();
}
Upvotes: 1