I'm working on a project using PHP/OCI8 and I decided to get fancy and route most of my database work through a set of Oracle stored procs/functions.
I have a function that takes a few arguments to create an entry in a "users" table. I chose to represent contact information for a user as an object (which is a child object of a User object, but I haven't gotten that far yet). The problem is that I can't for the life of me get PHP to successfully bind a variable with the named data type. I've done this before for arrays of custom types that are used in stored procs within a package (eliminates looped queries in PHP), but for some reason I can't get it to work just using a single variable of a custom type.
Here's some code. Note that my function is incomplete and just returns 1 for right now, I'm just trying to see if I can get it to execute successfully.
My type:
Code: Select all
create or replace type ContactInformation as object
(
street1 varchar2(256),
street2 varchar2(256),
city varchar2(128),
state char(2),
zip varchar2(10),
phone varchar2(16),
email varchar2(128)
);
Code: Select all
create or replace
function EE_newUser
(
argRole varchar2,
argSSO varchar2 default null,
argUserInfo EndUser default null,
argContactInfo ContactInformation
)
return integer
as
begin
return 1;
end EE_newUser;
Code: Select all
$conn = oci_connect("acct_name", "passwd", "connect_string");
class ContactInformation
{
public $street1;
public $street2;
public $city;
public $state;
public $zip;
public $phone;
public $email;
function __construct()
{
$this->street1 = "Test";
$this->street2 = "";
$this->city = "Test city";
$this->state = "MO";
$this->zip = "xxxxxx";
$this->phone = "555-5555";
$this->email = "some-email@email.com";
}
}
$contacts = new ContactInformation();
$testID = 0;
$statement = oci_parse($conn, "begin :id := EE_newUser('test', null, null, :contacts); end;");
oci_bind_by_name($statement, ":id", $testID, -1, SQLT_INT);
oci_bind_by_name($statement, ":contacts", $contacts, -1, SQLT_NTY);
oci_execute($statement);
oci_commit($conn);
echo "New ID: $testID<br />\n";
Code: Select all
Warning: oci_bind_by_name() [function.oci-bind-by-name]: Unable to find collection property in custom-types.php on line 34
I've been searching documentation and forum posts and so far haven't been able to figure it out.
Thanks in advance to anyone who might be able to help with this.
Jeremiah