I'm having a problem where PDO encapsulates int values using quotes and subsequently makes queries fail.
This is the code (using a wrapper function)
$newest = query("SELECT id, body, upvotes, downvotes
FROM suggestions ORDER BY timestamp DESC LIMIT :min, :max",
array(
':min' => $min,
':max' => $max
)
);
And this is the resulting bad query which causes an error (notice the quotes around the LIMIT values)
SELECT id, body, upvotes, downvotes FROM suggestions ORDER BY timestamp DESC LIMIT '0' , '50'
I'm passing an array of values:
array(
':min' => $min,
':max' => $max
)
They're both INTs, and from what I read on the internet PDO should automatically find that out and use PDO::PARAM_INT when binding them. The problem is it doesn't actually do that, and since my only way to pass them is through an array I'd like to ask if there's a way to force them to be PDO::PARAM_INT without having to use bindParam().
Thanks in advance.
$minand$maxexplicitly set to integers in PHP or not?