I had a problem using PDO because the error was not detected.
The code is simple and works just fine, I will just include a sample to avoid confusion:
$sql = 'INSERT INTO somedatetable (something)
VALUES (:something)
ON DUPLICATE KEY UPDATE something=:something';
$values = array(":something" => $something);
try {
$stmt = $dbh->prepare($sql);
$stmt->execute($values);
} catch (PDOException $e) {
echo "Error: " . $e->getMessage() . "<br />\n";
}
The code works fine, however, when working on a new module, I ran into a problem that no entries were added or changed, and an error was not detected.
$stmtcame back false, but I had no clue why and how to find a mistake.
The solution was simple at the end, I used a limited MySQL user who did not have write permissions to the table. These errors were always displayed immediately when using mysql, but using PDO I do not know how to get to them.
PHP/PDO ?