I am trying to convert a large SQL query to Propel.

if I add

->where("ads_table.date>DATE_SUB(CURDATE(),INTERVAL ? DAY)", $interval)

to the query and set $interval to 30, the generated SQL looks like this:

AND ads_table.date>DATE_SUB(CURDATE(),INTERVAL '1970-01-01 01:00:30' DAY)

How do I get it to see the parameter as an int?

有帮助吗?

解决方案

Ok, I found the answer in the Propel docs (I know).

->where("ads_table.date>DATE_SUB(CURDATE(),INTERVAL ? DAY)", $interval, \PDO::PARAM_INT)

does the trick.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top