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 seenlast;
I would like to use a PHP / PDO request, therefore:
$mymin=5; //this is a variable can be changed by $_GET $query = $db_conn->prepare("select * from users where now() - interval ':myminute minutes' < seenlast ORDER BY seenlast"); $query->bindParm(":myminute",$mymin) $query->execute;
This does not work, I can not find a way to pass the protocol correctly ( $ mymin ). If I programmed the timestuff hard, it means that the other part of the code must be correct.
I also tried:
$temp=$mymin." minutes"; $query = $db_conn->prepare("select * from users where now() - interval :myminute < seenlast ORDER BY seenlast"); $query->bindParm(":myminute",$temp)
I already saw it, didn't help
source share