File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1985,7 +1985,9 @@ PHP_METHOD(SQLite3Result, fetchArray)
19851985 Z_ADDREF (data );
19861986 }
19871987 }
1988- zend_symtable_add_new (Z_ARR_P (return_value ), result_obj -> column_names [i ], & data );
1988+ /* Note: we can't use the "add_new" variant here instead of "update" because
1989+ * when the same column name is encountered, the last result should be taken. */
1990+ zend_symtable_update (Z_ARR_P (return_value ), result_obj -> column_names [i ], & data );
19891991 }
19901992 }
19911993 break ;
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-11451 (Invalid associative array containing duplicate keys)
3+ --EXTENSIONS--
4+ sqlite3
5+ --FILE--
6+ <?php
7+ var_dump ((new SQLite3 (':memory: ' ))
8+ ->query ('SELECT 1 AS key, 2 AS key ' )
9+ ->fetchArray (SQLITE3_ASSOC ));
10+
11+ var_dump ((new SQLite3 (':memory: ' ))
12+ ->query ('SELECT 0 AS dummy, 1 AS key, 2 AS key ' )
13+ ->fetchArray (SQLITE3_ASSOC ));
14+ ?>
15+ --EXPECT--
16+ array(1) {
17+ ["key"]=>
18+ int(2)
19+ }
20+ array(2) {
21+ ["dummy"]=>
22+ int(0)
23+ ["key"]=>
24+ int(2)
25+ }
You can’t perform that action at this time.
0 commit comments