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

Bug #23736 MDB2::execute() fails to bind value types
Submitted: 2018-02-09 17:21 UTC
From: stanbery Assigned:
Status: Open Package: MDB2 (version 2.4.1)
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2018-02-09 17:21 UTC] stanbery (Larry Livingston Stanbery)
Description: ------------ MDB2.php - Line 4059 (v2.4.1) - Line 4406 (v2.5.0b5) function execute() calls bindValueArray() to attempt to bind types to values in the array; unfortunately, bindValueArray() defaults $types to null, and execute() never hands over the array of types. This results in blob fields being returned as string, unfortunately. Solution: change line to read: $err = $this->bindValueArray($values, $this->types); This provides the necessary types for binding, which allows prepared queries for blobs to work as desired. Test script: --------------- $db = MDB2::connect($connectStr); $dh = $db->prepare("insert into foo values (:data)", array("blob"), MDB2_PREPARE_MANIP); $dh->execute(array("data" => "file:///tmp/testfile")); $fh = fopen("foo.txt", "wb"); $dh2 = $db->prepare("select data from foo", null, array("blob")); $rs = $dh2->execute(null); $row = $rs->fetchRow(MDB2_FETCHMODE_ASSOC); while (!feof($row['data'])) { $x = fread($row['data'], 8192); fwrite($fh, $x); } fclose($fh); Expected result: ---------------- $row['data'] should be a resource type, not a string Actual result: -------------- $row['data'] is returned as a string

Comments