Page 1 of 1

Calling ORACLE stored function from php

Posted: Mon Jul 10, 2006 7:15 am
by Zoran_Dimov
I have this function declaration

FUNCTION GENSECURE RETURN VARCHAR2;

I am trying to call it in PHP with the following code

$sql="begin :bind = GENSECURE; end";
$s = ociparse($c, $sql);
OCIBindByName($s, ":bind", $user);
$result=ociexecute($s, OCI_DEFAULT);

The last command (ociexecute($s, OCI_DEFAULT); ) can't be executed. Can anyone tell me where am i wrong?

Thanks

Posted: Mon Jul 10, 2006 7:31 am
by sweatje
I have always used adodb as a database access layer to isolate me from the oci* details. Here is a simple example usind adodb (amp_adodb_connection is a factory function returning and adodb connection):

Code: Select all

$ php -r 'require_once "dblogin.php";
$c = amp_adodb_connection("prdcrm"); 
$c->debug=true; 
$rs = $c->executecursor("begin :r := pdftrade_web.getmonths; end;","r"); 
var_dump(count($rs->getArray()));'

InParameter($stmt, $php_var='', $name='r', $maxLen=-1, $type=116);
-----
(oci8): begin :r := pdftrade_web.getmonths; end;
-----
int(26)
ADOdb is also nice if you have to deal with blobs.