Hello. I am trying to search some records based on an interval:
$rates = ExchangeRate::find(array( "exchange_date BETWEEN DATE_SUB(DATE(:date:),INTERVAL 3 DAY) AND :date:", "bind" => array( 'date' => $date ), "cache" => array( "key" => "exchange_rate_$date", "lifetime" => 3600 * 24 ) ));
This will end up with the following error:
"Syntax error, unexpected token INTEGER(3), near to ' DAY) AND :date:', when parsing: SELECT [App\\Core\\Models\\Exchange\\ExchangeRate].* FROM [App\\Core\\Models\\Exchange\\ExchangeRate] WHERE exchange_date BETWEEN DATE_SUB(DATE(':date:'),INTERVAL 3 DAY) AND :date: (172
I have tried to bind the entire mysql function as \Phalcon\Db\RawValue(), but also without success:
new \Phalcon\Db\RawValue("DATE_SUB(DATE($date),INTERVAL 3 DAY)");
- I know how how to add and susbtract days via PHP, please comment strictly related to the ORM.