Home » Database » DB » Bug #4078
DB_PORTABILITY_LOWERCASE with OCI8 not working in all cases
Details
| Submitted | 2005-04-06 13:37 UTC |
|---|---|
| From | eckhard dot pruehs at snap dot de |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 5.0.3 |
| OS | All |
| Roadmaps | (Not assigned) |
Comments
[2005-04-06 13:37 UTC] eckhard dot pruehs at snap dot de
Description:
------------
I set DB_PORTABILITY_LOWERCASE to true and my fetchmode is DB_FETCHMODE_ASSOC when connecting to an Oracle-DB. I get results like:
Array
(
[0] => Array
(
[CF] => Juan
[NF] => 5
[DF] => 1991-01-11 21:31:41
)
[1] => Array
(
[CF] => Kyu
[NF] => 10
[DF] => 1992-02-12 22:32:42
)
)
The function "array_change_key_case" in method "fetchInto" could not convert this array to lowercase, because it can not handle multidimensional arrays.
Reproduce code:
---------------
$test = Array(
0 => Array (CF => "Juan", "NF" => "5", "DF" => "1991-01-11 21:31:41"),
1 => Array (CF => "Kyu", "NF" => "10", "DF" => "1992-02-12 22:32:42")
);
print_r (array_change_key_case($test));
print_r (array_change_key_case($test[0]));
[2005-04-06 13:53 UTC] eckhard dot pruehs at snap dot de
Why provide a test-script, when the PHP function "array_change_key_case" could not handle multi-dimensional arrays?
[2005-04-06 14:26 UTC] eckhard dot pruehs at snap dot de
Thats not so easy, because I develop on MYSQL and the live system is ORACLE. I have no create table access on the live machine.
This script should work:
/* create this table
CREATE TABLE test_table (
test_id NUMBER(11,0) NOT NULL,
field1 VARCHAR2(64) NOT NULL,
field2 VARCHAR2(64) NOT NULL,
field3 VARCHAR2(64) NOT NULL
PRIMARY KEY(test_id)
);
insert into test_table (test_id, field1, field2, field3) values (1, "test 1_1", "test 1_2", "test 1_3");
insert into test_table (test_id, field1, field2, field3) values (2, "test 2_1", "test 2_2", "test 2_3");
*/
require_once 'PEAR.php';
require_once 'DB.php';
$dsn = <your connection string>;
$dbh = DB::connect($dsn);
$dbh->setOption('portability', DB_PORTABILITY_LOWERCASE);
$sql = "SELECT * FROM test_table WHERE test_id > ?";
$result = $dbh->getAssoc($sql, false, 0, DB_FETCHMODE_ASSOC);
print_r($result);
print_r(array_change_key_case($result[1], CASE_LOWER));
[2005-04-06 16:40 UTC] eckhard dot pruehs at snap dot de
OK, I found the bug. It's a other bug:
Line 372 is wrong:
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $moredata)
Correct is:
if ($this->options['portability'] && DB_PORTABILITY_LOWERCASE && $moredata)