Closed
Description
Description
The following code:
<?php
declare(strict_types=1);
$pdo = new PDO('mysql:host=localhost;dbname=demo;charset=utf8mb4', 'user', 'pass');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->exec('DROP TABLE IF EXISTS test');
$pdo->exec('CREATE TABLE test (mode TINYINT)');
$statement = $pdo->prepare('INSERT INTO test (mode) VALUES (?)');
$statement->bindValue(1, new DateTime(), PDO::PARAM_INT);
$success = $statement->execute();
$error = $pdo->errorInfo();
var_dump($success);
var_dump($error);
Resulted in this output:
bool(false)
array(3) {
[0]=>
string(5) "00000"
[1]=>
NULL
[2]=>
NULL
}
But I expected this output instead:
An unsuccessful PDO command should throw an exception.
PHP Version
PHP 8.1.2
Operating System
Ubuntu 22.04.3