Bug #18524 [Opn]: MDB2_PORTABILITY_FIX_CASE doesn't have any effect

From: Date: Sun, 01 Apr 2012 15:09:24 +0000
Subject: Bug #18524 [Opn]: MDB2_PORTABILITY_FIX_CASE doesn't have any effect
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8493@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=18524&edit=1 ID: 18524 Updated by: daniel.oconnor@gmail.com Reported By: nick at deltamotion dot com Summary: MDB2_PORTABILITY_FIX_CASE doesn't have any effect Status: Open Type: Bug Package: MDB2_Driver_sqlsrv Operating System: Windows Package Version: 1.5.0b3 PHP Version: 5.3.6 Roadmap Versions: New Comment: Bug #19342 Previous Comments: ------------------------------------------------------------------------ [2011-05-10 20:49:22] nickmc Description: ------------ MDB2_PORTABILITY_FIX_CASE doesn't seem to do anything. I noticed this when I switched from the mssql driver to sqlsrv (the only change in my code to create the problem), and all my associative arrays ended up with undefined indexes because they now contained mixed case rather than being entirely lowercase. I dug around a bit in MDB2\Driver\sqlsrv.php, and I found that the check for ($fetchmode == MDB2_FETCHMODE_ASSOC) before applying MDB2_PORTABILITY_FIX_CASE was false although I specified MDB2_FETCHMODE_ASSOC. I checked the value for $fetchmode and it was MDB2_FETCHMODE_DEFAULT. Adding the following code immediately before that check seemed to fix the problem, but I'm not sure whether it's the proper way to fix the problem, or if there are other implications. This is from fetchRow(). if($fetchmode == MDB2_FETCHMODE_DEFAULT) $fetchmode = $this->db->fetchmode; The relevant section of code, altogether, is: if($fetchmode == MDB2_FETCHMODE_DEFAULT) $fetchmode = $this->db->fetchmode; if ($fetchmode == MDB2_FETCHMODE_ASSOC && is_array($row) && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { $row = array_change_key_case($row, $this- >db- >options['field_case']); } Test script: --------------- $mdb2 =& MDB2::factory('sqlsrv://user:pass@server/Database'); $mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC); $mdb2->setOption('field_case', CASE_LOWER); $mdb2->setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL); $statement = $mdb2->prepare('select SomeRow from table'); $result = $statement->execute(); $data = $result->fetchAll(); var_dump($data); Expected result: ---------------- // this is the output of the above script. notice that // SomeRow is not lowercase array(1) { [0]=> array(2) { ["SomeRow "]=> string(4) "1234" [0]=> string(4) "1234" } } Actual result: -------------- array(1) { [0]=> array(2) { ["somerow"]=> string(4) "1234" [0]=> string(4) "1234" } } ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=18524&edit=1

« previous php.pear.bugs (#8493) next »