Passing 2D arrays from PHP to Oracle
am 09.11.2007 10:36:11 von andymconlineHello all,
I have an existing Oracle database application that requires a
"simple" front-end (do these things ever turn out to be simple?).
There is an existing API written which I would like to reuse if
possible. Here is a snippet of the API:
TYPE property IS RECORD
( property_key VARCHAR2(8)
, property_value VARCHAR2(128) );
TYPE property_array IS TABLE OF property
INDEX BY BINARY INTEGER;
PROCEDURE create_customer( i_customer_id IN customer.customer_id%TYPE
, i_properties IN property_array )
IS
BEGIN
...
END create_customer;
In PHP I would like to call the create_customer procedure so would
need something like:
....
// Set-up some dummy values
$cust_id = 1
$properties = array( 'FNAME' => 'John'
, 'LNAME' => 'Smith'
, 'DOB' => '01-JAN-2007' );
$conn = oci_connect("dev", "dev", "//localhost/XE");
$stmt = oci_parse($conn, 'begin
create_customer(:cust_id, :properties); end;');
oci_bind_by_name($stmt, ':cust_id', $cust_id, -1, OCI_B_NTY);
oci_bind_array_by_name($stmt, ":properties", $properties,
count($properties), -1, SQLT_CHR);
oci_execute($stmt);
This doesn't seem to work - I've RTFM but can't seem to find any doco
on this (I've seem simple 1-dimensional array examples but nothing on
2D arrays). Is this even possible?
Any help would be gratefully appreciated!
Cheers
Andy