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

Bug #16246 bindParam doesnt work with out params under oci8
Submitted: 2009-05-21 16:35 UTC
From: hannibal218 Assigned:
Status: Open Package: MDB2_Driver_oci8
PHP Version: 5.2.9 OS: centos 5.2 64bit
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 22 - 17 = ?

 
 [2009-05-21 16:35 UTC] hannibal218 (dor zaidenberg)
Description: ------------ if you try to call a stored procedure under mdb2 oci8, and that procedure has out params. you dont get the out params back. i think that this actually breaks into two seperate problems. the first one is that the calls to @OCIBindByName are missing a third variable that gives the size of the expected return value. if , i changed localy : if (!@OCIBindByName($this->statement, ':'.$parameter, $quoted_values[$i])) { to : if(!@OCIBindByName($this->statement, ':'.$parameter, $quoted_values[$i],32)) this gave me the out param values stored inside the $quoted_values array, this leads me to the second bug: quoted_values is lost inside the function, its data is not added to the object returned by function my solution which is bad, was to add a third reference parameter to the _execute function, to hold that array : &_execute($result_class = true, $result_wrap_class = false , &$result_params = array()) Test script: --------------- 2 <?php 3 require_once "MDB2.php"; 4 5 /* 6 //sayHello syntax 7 CREATE OR REPLACE PROCEDURE 8 sayHello (name IN VARCHAR2, greeting OUT VARCHAR2) 9 AS 10 BEGIN 11 greeting := 'Hello ' || name; 12 END; 13 14 */ 15 16 17 $sql = 'begin sayHello(:inName, :inMessage); end;'; 18 $name = "dor"; 19 $connStr = "oci8://dispatcher:daparISZ@localhost/vcdb.videocells.com"; 20 echo " ****************** OCI_INTERFACE **************** <BR>"; 21 22 $conn = oci_connect("dispatcher","daparISZ","localhost/vcdb.videocells.com"); 23 $stmt = oci_parse($conn,$sql); 24 oci_bind_by_name($stmt,':inName',$name,32); 25 oci_bind_by_name($stmt,':inMessage',$message_OCI,32); 26 oci_execute($stmt); 27 echo "message_OCI = $message_OCI <br>"; 28 29 echo " ****************** OCI_INTERFACE_END *********** <BR>"; 30 echo " ****************** MDB_INTERFACE_START ********* <BR>"; 31 $mdb2 =& MDB2::connect($connStr); 32 if (PEAR::isError($mdb2)) 33 { 34 die(__FILE__ ." ". __LINE__ ." : ". $mdb2->getMessage()); 35 } 36 37 $mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC); 38 $mdb2->LoadModule('Extended'); 39 40 $statement = $mdb2->prepare($sql); 41 $statement->bindParam("inName",$name); 42 $statement->bindParam("inMessage",$message_MDB); 43 $res = $statement->execute(); 44 echo "message_MDB = $message_MDB <br>"; 45 $statement->free(); 46 echo " ***************** MDB_INTERFACE_END *********** <BR>"; 47 48 ?> 49 Expected result: ---------------- ****************** OCI_INTERFACE **************** message_OCI = Hello dor ****************** OCI_INTERFACE_END *********** ****************** MDB_INTERFACE_START ********* message_MDB = Hello dor ***************** MDB_INTERFACE_END *********** Actual result: -------------- ****************** OCI_INTERFACE **************** message_OCI = Hello dor ****************** OCI_INTERFACE_END *********** ****************** MDB_INTERFACE_START ********* message_MDB = ***************** MDB_INTERFACE_END ***********

Comments

 [2009-05-21 16:45 UTC] hannibal218 (dor zaidenberg)
correction to my first fix which didnt work. i've noticed that result_types is allways null so i have added this line before the _wrapResult function call : $this->result_types = $quoted_values; this gaves me the values i wanted finally from the out parameters. on a general note, the oci8 interface is far from being smooth like the mysql one
 [2009-05-23 21:43 UTC] doconnor (Daniel O'Connor)
-Package: pearweb +Package: MDB2
 [2010-06-10 14:57 UTC] alec (Aleksander Machniak)
-Package: MDB2 +Package: MDB2_Driver_oci8