How to insert things like “now() -interval '2 minutes'” into PHP PDO query?

后端 未结 4 1191
无人共我
无人共我 2021-01-11 20:14

I have a query like this: (on Postgresql 8.4, PHP-fpm 5.3.10 (fpm-fcgi))

select * from users where now() - interval \'2 minutes\' < seenlast ORDER BY seen         


        
4条回答
  •  -上瘾入骨i
    2021-01-11 20:57

    Intervals can be multiplied by numbers. So one approach to this is to prepare the statement saying interval '1 minute' * :myminutes instead, passing the "myminutes" parameter as a simple integer.

提交回复
热议问题