[php-src] Issue #11744: Duplicate prepare statements when a value is bound as PDO::PARAM_INT

From: Date: Wed, 19 Jul 2023 13:37:10 +0000
Subject: [php-src] Issue #11744: Duplicate prepare statements when a value is bound as PDO::PARAM_INT
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244999@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11744
Author: ionutantohi

### Description

The following code:

```php
$pdo = new PDO("mysql:host=localhost;port=3306;dbname={database_name}",
'{username}', '{password}', [
    PDO::ATTR_EMULATE_PREPARES => false,
]);

$statement = $pdo->prepare('select * from users where
users.id = ? limit 1');

$statement->bindValue(1, 1, PDO::PARAM_INT);

$statement->execute();
<?php
```

Resulted in this output in mysql query log
```
146 Prepare	select * from users where users.id = ? limit 1
146 Prepare	select * from users where users.id = ? limit 1
146 Execute	select * from users where users.id = 1 limit 1
146 Close stmt
```

But I expected this output instead:
```
146 Prepare	select * from users where users.id = ? limit 1
146 Execute	select * from users where users.id = 1 limit 1
146 Close stmt
```

Note: When the value is bound as PDO::PARAM_STR, only 1 prepare statement is executed as expected.

### PHP Version

8.1.21

### Operating System

_No response_


Thread (1 message)

  • ionutantohi
« previous php.bugs (#244999) next »