As stated in the documentation for
An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as
For the most part, this goes entirely unnoticed as MySQL's implicit type conversion handles the rest (but it can cause some undesirable behaviour if MySQL is using a particularly weird connection character set, as converting strings of numbers back to their numeric value might not give the expected result).
In your case, MySQL is attempting to execute a
LIMIT clause that has string arguments. Whilst it could attempt to resolve that using its implicit type conversion, as it does everywhere else a string appears where an integer should be, it simply doesn't bother and runs off crying instead.
So, you need to tell PDO that these particular parameters are integers. Since even PHP doesn't know what type its variables are, I believe the only way to do that is to directly bind them with either
PDOStatement::bindValue as you are doing (although it isn't strictly necessary to specify the
$data_type argument as a simple
(int) cast of the
$variable gives PHP's otherwise clueless type system enough to work with).
As far as the internal method PDO uses to bind parameters to a variable goes, take a look at
really_register_bound_param() (unsurprisingly not exposed to PHP, so you'll be having lots of fun in C).