PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #104

query() does not return bind variable in stored procedure call

Details

Submitted2003-10-15 15:26 UTC
Fromblazicek at bof dot sk
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.3
OSLinux
Roadmaps(Not assigned)

Comments

[2003-10-15 15:26 UTC] blazicek at bof dot sk

Description:
------------
No value is returned to bind variable, when calling stored procedure, which returns value in parameter.

Connect type: OCI8

Reproduce code:
---------------
$tmp = ' ';
$query = "BEGIN test('param1',?); END;";
$res = $this->db->query($query, &$tmp);

PROCEDURE TEST(param in varchar2, param2 OUT VARCHAR2)
IS
BEGIN
...
param2 := 'something';
...
END;

Expected result:
----------------
'something' in $tmp

Actual result:
--------------
$tmp is unchanged

It can be solved by adding & in common.php on line 758

$ret = $this->execute($sth, &$params);

When $params are passed by reference, it works fine.

[2004-01-16 13:47 UTC] blazicek at bof dot sk

diff output is as follows

diff -u -r1.49 common.php
--- DB/common.php 16 Jan 2004 04:21:00 -0000 1.49
+++ DB/common.php 16 Jan 2004 13:26:21 -0000
@@ -773,7 +773,7 @@
if (DB::isError($sth)) {
return $sth;
}
- $ret =& $this->execute($sth, $params);
+ $ret =& $this->execute($sth, &$params);
$this->freePrepared($sth);
return $ret;
} else {
@@ -1546,4 +1546,4 @@
* End:
*/

-?>
+?>
\ No newline at end of file

and with following sources you can reproduce the bug

<?
require_once 'DB.php';
$db = DB::connect('oci8://www:www@mark', TRUE);

$tmp = array(" ");

$query = "BEGIN test('param1',?); END;";
$res = $db->query($query, &$tmp);

var_dump($tmp);

?>

CREATE OR REPLACE PROCEDURE WWW.TEST
( param1 IN varchar2,
param2 IN OUT varchar2)
IS
BEGIN

param2 := 'something';

END; -- Procedure

output before

array(1) { [0]=> string(28) " " }

output after change

array(1) { [0]=> &string(9) "something" }