From f9e108ac845fbc075a9eb63d05120e9e5618ff49 Mon Sep 17 00:00:00 2001 From: Ron Chmara Date: Sat, 30 Sep 2000 18:30:12 +0000 Subject: [PATCH] Added OCIFreeDesc, fixed typos, added intro and hints to set env variables properly. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@33202 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/oci8.xml | 134 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 125 insertions(+), 9 deletions(-) diff --git a/functions/oci8.xml b/functions/oci8.xml index b03b6ff937..cab879763e 100644 --- a/functions/oci8.xml +++ b/functions/oci8.xml @@ -2,17 +2,113 @@ Oracle 8 functions OCI8 - - These functions allow you to access Oracle8 and Oracle7 databases. It - uses the Oracle8 Call-Interface (OCI8). You will need the Oracle8 client - libraries to use this extension. - - + + These functions allow you to access Oracle8 and Oracle7 databases. + It uses the Oracle8 Call-Interface (OCI8). You will need the Oracle8 + client libraries to use this extension. + + This extension is more flexible than the standard Oracle extension. It supports binding of global and local PHP variables to Oracle placeholders, has full LOB, FILE and ROWID support and allows you to use user-supplied define variables. - + + + Before using this extension, make sure that you have set up your + oracle environment variables properly for the Oracle user, as well + as your web daemon user. The variables you might need to set are as + follows: + + + + ORACLE_HOME + + + + + ORACLE_SID + + + + + LD_PRELOAD + + + + + LD_LIBRARY_PATH + + + + + NLS_LANG + + + + + ORA_NLS33 + + + + + + After setting up the environment variables for your webserver user, + be sure to also add the webserver user (nobody, www) to the oracle + group. + + + + OCI Hints + +<?php +// by sergo@bacup.ru + +// Use option: OCI_DEFAULT for execute command to delay ececution +OCIExecute($stmt, OCI_DEFAULT); + +// for retrieve data use (after fetch): + +$result = OCIResult($stmt, $n); +if (is_object ($result)) $result = $result->load(); + +// For INSERT or UPDATE statetment use: + +$sql = "insert into table (field1, field2) values (field1 = 'value', + field2 = empty_clob()) returning field2 into :field2"; +OCIParse($conn, $sql); +$clob = OCINewDescriptor($conn, OCI_D_LOB); +OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); +OCIExecute($stmt, OCI_DEFAULT); +$clob->save ("some text"); + +?> + + + + + You can easily access stored procedures in the same way as you + would from the commands line. + + Using Stored Procedures + +<?php +// by webmaster@remoterealty.com +$sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname', + '$lastname', '$company', '$address1', '$address2', '$city', '$state', + '$postalcode', '$country', :error_code );end;" ); + +// This calls stored procedure sp_newaddress, with :address_id being an +// in/out variable and :error_code being an out variable. +// Then you do the binding: + + OCIBindByName ( $sth, ":address_id", $addr_id, 10 ); + OCIBindByName ( $sth, ":error_code", $errorcode, 10 ); + OCIExecute ( $sth ); + +?> + + +