mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
MFH: Bug #45458 (OCI8: Numeric keys for associative arrays are not handled properly)
This commit is contained in:
parent
38b404fcb6
commit
c5aa4a138e
@ -1399,7 +1399,7 @@ PHP_FUNCTION(oci_fetch_all)
|
||||
if (flags & PHP_OCI_NUM) {
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(row), &element, sizeof(zval*), NULL);
|
||||
} else { /* default to ASSOC */
|
||||
zend_hash_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL);
|
||||
zend_symtable_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1431,7 +1431,7 @@ PHP_FUNCTION(oci_fetch_all)
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
array_init(tmp);
|
||||
zend_hash_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ]));
|
||||
zend_symtable_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ]));
|
||||
}
|
||||
}
|
||||
|
||||
|
84
ext/oci8/tests/bug45458.phpt
Normal file
84
ext/oci8/tests/bug45458.phpt
Normal file
@ -0,0 +1,84 @@
|
||||
--TEST--
|
||||
Bug #45458 (OCI8: Numeric keys for associative arrays are not handled properly)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require(dirname(__FILE__).'/connect.inc');
|
||||
|
||||
// Run Test
|
||||
|
||||
echo "Test 1\n";
|
||||
|
||||
$stmt = 'select dummy "a", dummy "20" from dual';
|
||||
|
||||
$s = oci_parse($c, $stmt);
|
||||
oci_execute($s);
|
||||
$r = oci_fetch_all($s, $data, 0, -1, OCI_FETCHSTATEMENT_BY_ROW);
|
||||
var_dump($data);
|
||||
var_dump($data[0]);
|
||||
var_dump($data[0]["a"]);
|
||||
var_dump($data[0]["20"]);
|
||||
oci_free_statement($s);
|
||||
|
||||
echo "Test 2\n";
|
||||
|
||||
$s = oci_parse($c, $stmt);
|
||||
oci_execute($s);
|
||||
$r = oci_fetch_all($s, $data, 0, -1, OCI_ASSOC);
|
||||
var_dump($data);
|
||||
var_dump($data["a"]);
|
||||
var_dump($data["20"]);
|
||||
var_dump($data["a"][0]);
|
||||
var_dump($data["20"][0]);
|
||||
oci_free_statement($s);
|
||||
|
||||
oci_close($c);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
<?php exit(0); ?>
|
||||
--EXPECT--
|
||||
Test 1
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["a"]=>
|
||||
string(1) "X"
|
||||
[20]=>
|
||||
string(1) "X"
|
||||
}
|
||||
}
|
||||
array(2) {
|
||||
["a"]=>
|
||||
string(1) "X"
|
||||
[20]=>
|
||||
string(1) "X"
|
||||
}
|
||||
string(1) "X"
|
||||
string(1) "X"
|
||||
Test 2
|
||||
array(2) {
|
||||
["a"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "X"
|
||||
}
|
||||
[20]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "X"
|
||||
}
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "X"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "X"
|
||||
}
|
||||
string(1) "X"
|
||||
string(1) "X"
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user