So general it cannot be fixed.

PHP’s PDO library (MySQL driver) has been throwing strange exceptions for any insert/update/delete queries:

Database error: SQLSTATE[HY000]: General error

It doesn’t matter what the query is.

$stmt = $pdo->prepare();

seems to be the problem, but the exception is also thrown with




. Persistent connections don’t make a difference. Running the query from the mysql command line is fine. But the truly bizare thing: all the queries succeed.

The magical fix

Apparently, this has something to do with how PDO emulates prepared queries and MySQL. So turing off emulated prepared queries (and going for real prepared queries) fixes the problem. Hurrah.

$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

PHP 5.3.8, MySQL 5.5.16, Apache 2.2