How write this Phalcon\Model query?
SELECT * FROM reset WHERE createdon < UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY )
reset
Thanks.
This syntax is not supported because it's a MySQL extension that cannot be translated by PHQL when using PostgreSQL/SQlite/Oracle. You can use a raw sql query in this case: https://docs.phalcon.io/en/latest/reference/phql.html#using-raw-sql
Another way is to using the MysqlExtended Dialect class: https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Db/Dialect
MysqlExtended
it works : )
$day = time()-86400; $rs = Reset::find("createdon < $day");
$day = time()-86400;
$rs = Reset::find("createdon < $day");
It is bab practice to inject criteria params into PHQL. You have to use bind in order to allow PHQL engine use query cache:
bind
$rs = Reset::find([ 'createdon > :day:', 'bind' => [ 'day' => time() - 86400 ] ]);
For more information see: https://docs.phalcon.io/en/latest/reference/models.html#binding-parameters