[php-src] Issue #8668: mysqli_execute wrong type in JSON_SET, should be integer
| From: | laukstein | Date: | Tue, 31 May 2022 20:04:34 +0000 |
| Subject: | [php-src] Issue #8668: mysqli_execute wrong type in JSON_SET, should be integer | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241632@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8668
Author: laukstein
### Description
https://wiki.php.net/rfc/mysqli_execute_query
says:
> Since PHP 8.1, we no longer have problems with binding by reference, or needing to specify the
> variable types via the first argument to bind_param()
This works fine for like
UPDATE images SET width=? WHERE id=? but not inside JSON,
example bellow:
The following code:
```php
$statement = $db->prepare('UPDATE images SET sizes=JSON_SET(sizes, '$.width', ?)
WHERE id=?');
$width = 123; // Is type (int)
$id = 'test';
$statement->execute([$width, $id]); // Will add width "123" as a string and not integer
- is a BUG
```
Resulted in this output (width type str):
| id | sizes |
|---|---|
| test | {width: **"123"**} |
But I expected this output instead (width type int):
| id | sizes |
|---|---|
| test | {width: **123**} |
Probably the same bug is in PHP 8.2 mysqli_execute_query.
### PHP Version
PHP 8.1.6
### Operating System
Windows 10