PHP and ODBC with Oracle Database
SKellyJan 26 2012 — edited Jan 27 2012Sorry in advance - I am a newbie to the Oracle database and how to write PHP code to talk with Oracle.
I have this PHP code that I used for extracting data from a SQL Server DB using an ODBC connection. When we call the public function in SQL Server it returns the result in a table type format where we use a SELECT statement to retrieve the data to use in the application
In SQL Server this is the PHP code:
public function generateMasterKey($project_name, $table_name) {
$master_key = odbc_result($this->odbc->Prepare("DECLARE @as_master_key varchar(26) EXEC [dbo].[GET_UNIQUE_MASTER_KEY] @as_project_name = N'$project_name', @as_database_site = N'CMPL', @as_user_initials = N'SK', @as_table = N'".$table_name."', @as_master_key = @as_master_key OUTPUT SELECT @as_master_key as N'master_key'"), 'master_key');
return $master_key;
}
My public function uses the "odbc_result" PHP function to use the GET_UNIQUE_MASTER_KEY procedure within the SQL Server database then use the SELECT statement to capture that result into a variable that I can use in my PHP application
When I test some code for Oracle and I use the Oracle DB front end to enter a statement:
DECLARE
master_key VARCHAR2(26);
BEGIN
get_unique_master_key('DEMO','CMPL','SK','DWMT_TABLE',master_key);
dbms_output.put_line(master_key);
END;
The Oracle front end returns a correct value (a single generated master key) but it is just returning the value. I do not know how to use the PHP "odbc_result" to actually retrieve the data within PHP to be used. I think I am 98% there - but am having trouble with the last 2%