[php-src] Issue #13167: PDO: No exception when wrong data is bound to statement
| From: | butesa | Date: | Tue, 16 Jan 2024 19:44:59 +0000 |
| Subject: | [php-src] Issue #13167: PDO: No exception when wrong data is bound to statement | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246272@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13167
Author: butesa
### Description
The following code:
```php
<?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