$pdo->commit(); // real commit catch (Exception $e) $pdo->rollback(); // full rollback
– replace one IN(?) placeholder at a time, and you’ll wonder how you ever lived without array expansion. Have you tried PDO v2.0’s extended features in your projects? Share your experiences or migration tips in the comments below. pdo v2.0 extended features
try $pdo->insert('users', ['email' => 'exists@example.com']); catch (ConstraintViolationException $e) // Duplicate entry – handle gracefully try $pdo->insert('users', ['email' => 'exists@example
For static analysis tools like Psalm or PHPStan, PDO v2.0 allows #[ExpectedType] attributes: catch (PDOException $e) echo $e->
try $pdo->query("INVALID SQL"); catch (PDOException $e) echo $e->getMessage(); // "SQLSTATE[42000]: Syntax error" $prev = $e->getPrevious(); if ($prev instanceof MySQLDriverException) echo "MySQL error code: " . $prev->getCode();
// Auto-casting // DB row: ['id' => '42', 'is_active' => '1'] class User public int $id; // becomes 42 public bool $is_active; // becomes true