Don't emulate prepared statements
While building a PHP tool today an error occurred when executing a prepared SQL statement with PDO:
Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '10'' at line 5...This occurred in two bound values for a
LIMIT
clause. The SQL
seemed to contain the values between quotes, like limit '0', '10'
.
At first I thought the values were strings, but that was wrong. The values are
integers and are bound with the right type, PDO::PARAM_INT
.
An old answer helped to
solve the problem. After changing PDO setting
PDO::ATTR_EMULATE_PREPARES
to FALSE
the code ran
fine.