Bug #81103 [NEW]: mysqli_both overwrites numerical indexes
| From: | dharman@php.net | Date: | Thu, 03 Jun 2021 19:35:32 +0000 |
| Subject: | Bug #81103 [NEW]: mysqli_both overwrites numerical indexes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-234196@lists.php.net to get a copy of this message | ||
From: dharman
Operating system:
PHP version: 7.4.20
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli_both overwrites numerical indexes
Description:
------------
Per the documentation
"If two or more columns of the result have the same field names, the
last column will take precedence and overwrite the earlier data. In
order to access multiple columns with the same name, the numerically
indexed version of the row must be used."
When executing a query with numerical column names, associative names
overwrite the numerical indices. For example, in the code below it is
impossible to access value 'a' as it has been overwritten with 'b'
Test script:
---------------
$res = $mysqli->query("SELECT 'abc', 'a' AS
1,
'b' AS 1");
var_dump($res->fetch_array());
Expected result:
----------------
array(4) {
[0]=>
string(3) "abc"
["abc"]=>
string(3) "abc"
[1]=>
string(1) "b"
[2]=>
string(1) "b"
}
Actual result:
--------------
array(4) {
[0]=>
string(3) "abc"
["abc"]=>
string(3) "abc"
[1]=>
string(1) "a"
[2]=>
string(1) "b"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=81103&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81103&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81103&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81103&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81103&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81103&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81103&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81103&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81103&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81103&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81103&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81103&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81103&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81103&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81103&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81103&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81103&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81103&r=mysqlcfg