Bug #16246 [Opn]: bindParam doesnt work with out params under oci8
| From: | alec at alec dot pl | Date: | Thu, 10 Jun 2010 10:57:06 +0000 |
| Subject: | Bug #16246 [Opn]: bindParam doesnt work with out params under oci8 | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-3919@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=16246&edit=1
ID: 16246
Updated by: alec@alec.pl
Reported By: hannibal218 at gmail dot com
Summary: bindParam doesnt work with out params under oci8
Status: Open
Type: Bug
-Package: MDB2
+Package: MDB2_Driver_oci8
Operating System: centos 5.2 64bit
PHP Version: 5.2.9
Roadmap Versions:
New Comment:
-Package: MDB2
+Package: MDB2_Driver_oci8
Previous Comments:
------------------------------------------------------------------------
[2009-05-23 17:43:21] doconnor
-Package: pearweb
+Package: MDB2
------------------------------------------------------------------------
[2009-05-21 12:45:38] hannibal218
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-21 12:35:47] hannibal218
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 ***********
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16246&edit=1