code:
$report = StatReport::findFirst([
'columns' => 'sum(if(report_at = DATE_ADD(report_at, INTERVAL(-WEEKDAY(report_at)) DAY), reg_num,0)) as w1',
'conditions' => 'report_at >= "2018-09-01"',
]);
var_dump($report);exit;
exception:
Syntax error, unexpected token IDENTIFIER(DAY), near to '), reg_num,0)) as w1 FROM [StatReport] WHERE report_at >= "2018-09-01" LIMIT :APL0:', when parsing: SELECT sum(if(report_at = DATE_ADD(report_at, INTERVAL(-WEEKDAY(report_at)) DAY), reg_num,0)) as w1 FROM [StatReport] WHERE report_at >= "2018-09-01" LIMIT :APL0: (162)<br><pre>#0 [internal function]: Phalcon\Mvc\Model\Query->parse()
sql run in mysql is normal, but cant execute in phalcon:
select sum(if(report_at = DATE_ADD(report_at, INTERVAL(-WEEKDAY(report_at)) DAY), reg_num, 0)) as w1
from stat_report
where report_at >= '2018-09-01';