P. 1
phpyoracle

phpyoracle

|Views: 623|Likes:
Published by Dunkel Kruspe

More info:

Categories:Types, Research
Published by: Dunkel Kruspe on Apr 05, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/03/2011

pdf

text

original

An alternative solution lets you use the fast oci_bind_array_by_name() function. The wrapper
procedure looks like:

Script 49: objectba.sql

create or replace procedure mywrapper2(
pempno out dbms_sql.number_table,
pename out dbms_sql.varchar2_table) as origdata mytabletype;

begin

mycreatedata(origdata); -- create some values
select myid, mydata
bulk collect into pempno, pename
from table(cast(origdata as mytabletype));
end mywrapper2;
/
show errors

This can be called from PHP with:

Script 50: obejctba.php

$c = oci_connect("hr", "hrpwd", "localhost/XE");

$s = oci_parse($c, "begin mywrapper2(:myid, :mydata); end;");
oci_bind_array_by_name($s, ":myid", $myid, 10, -1, SQLT_INT);
oci_bind_array_by_name($s, ":mydata", $mydata, 10, 20, SQLT_CHR);
oci_execute($s);

var_dump($myid);
var_dump($mydata);

?>

This technique can be used when the number of items to return is known. The output is:

array(5) {
[0]=>
int(2)
[1]=>

179

Using PL/SQL With OCI8

int(4)
[2]=>
int(6)
[3]=>
int(8)
[4]=>
int(10)

}
array(5) {
[0]=>
string(11) "some name 1"
[1]=>
string(11) "some name 2"
[2]=>
string(11) "some name 3"
[3]=>
string(11) "some name 4"
[4]=>
string(11) "some name 5"

}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->