Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b5

Bug #18524 MDB2_PORTABILITY_FIX_CASE doesn't have any effect
Submitted: 2011-05-11 00:49 UTC
From: nickmc Assigned:
Status: Open Package: MDB2_Driver_sqlsrv (version 1.5.0b3)
PHP Version: 5.3.6 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2011-05-11 00:49 UTC] nickmc (Nick McClellan)
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" } }

Comments

 [2012-04-01 20:09 UTC] doconnor (Daniel O'Connor)