I’ve set up PHP (5.2) with PDO (MySQL 5.1) to throw exceptions when an error occurs:
$pdo = new PDO(...);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Now, I get sometimes an exception that only tells me “HY000: General error”. I’ve tried to get more info out of PDO, but all I can say is that:
- errorInfo():
array(0 => 'HY000') - errorCode():
array(0 => '00000')
The query that fails looks like this:
INSERT INTO user_values
SELECT user_id,
attribute_id,
?,
value
FROM user_values
WHERE user_id = ?
AND set_id = ?
I’ve ensured that all cursors are properly closed ($stmt->closeCursor()). The exception is thrown when calling fetchAll() on my statement. After some searching around I found that some are just ignoring this error, but it seems just plain wrong to dismiss a PDO exception.
What to do? Do I have to check like “It’s an INSERT, there is no result set so ignore those exception” (as I don’t have separate methods for INSERT, SELECT, UPDATE, …).
error code 00000 means successful (or rather no error found).