From 810cf8cd0afae1710927cab159bba312dc0b816b Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 17 Nov 2009 21:20:52 +0000 Subject: [PATCH] Explain default commit mode when querying. Add literal/constant tags & use tables. Standardize examples. Update oci_close doc and add examples git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290888 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/oci8/examples.xml | 122 ++++++++------ reference/oci8/functions/oci-close.xml | 196 +++++++++++++++++++++- reference/oci8/functions/oci-commit.xml | 21 +-- reference/oci8/functions/oci-execute.xml | 149 ++++++++++------ reference/oci8/functions/oci-parse.xml | 25 ++- reference/oci8/functions/oci-rollback.xml | 25 +-- 6 files changed, 400 insertions(+), 138 deletions(-) diff --git a/reference/oci8/examples.xml b/reference/oci8/examples.xml index b9cf618a20..8e83c0616d 100644 --- a/reference/oci8/examples.xml +++ b/reference/oci8/examples.xml @@ -2,32 +2,47 @@ &reftitle.examples; + + These examples connect as the HR user, which is + the sample "Human Resources" schema supplied with the + Oracle database. The account may need to be unlocked and the + password reset before you can use it. + + + + The examples connect to the XE database on your + machine. Change the connect string to your database before running + the examples. + + + + Basic query - Basic queries in oci8 use a prepare-execute-fetch sequence of steps. - - Basic query - + This shows querying and displaying results. Statements in OCI8 use + a prepare-execute-fetch sequence of steps. + + \n"; while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) { print "\n"; foreach ($row as $item) { - print " ".($item != null ? htmlentities($item) : " ")."\n"; + print " " . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "\n"; } print "\n"; } @@ -46,18 +61,17 @@ oci_close($conn); ?> ]]> - - - - + + + + Inserting with bind variables - Bind variables improve performance by allowing reuse of execution - contexts and caches. Bind variables improve security by - preventing some kinds of SQL Injection problems. - - Inserting with bind variables - + Bind variables improve performance by allowing reuse of execution + contexts and caches. Bind variables improve security by preventing + some kinds of SQL Injection problems. + + ]]> - - - - + + + + Inserting data into a CLOB column - For large data use binary long object (BLOB) or character long object (CLOB) types. - - Inserting data into a CLOB column - + For large data use binary long object (BLOB) or character long + object (CLOB) types. This example uses CLOB. + + save("A very long string"); oci_commit($conn); @@ -131,27 +146,27 @@ $query = 'SELECT myclob FROM mytable WHERE mykey = :mykey'; $stid = oci_parse ($conn, $query); oci_bind_by_name($stid, ":mykey", $mykey, 5); -oci_execute($stid, OCI_DEFAULT); +oci_execute($stid); print ''; while ($row = oci_fetch_array($stid, OCI_ASSOC)) { - $result = $row['MYCLOB']->load(); - print ''; + $result = $row['MYCLOB']->load(); + print ''; } print '
'.$result.'
'.$result.'
'; ?> ]]> -
-
- - + + + + Using a PL/SQL stored function - You can easily access stored PL/SQL functions and procedures. - - Using a stored function - + You must bind a variable for the return value and optionally for + any PL/SQL function arguments. + + '; $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); - trigger_error(htmlentities($e['message']), E_USER_ERROR); + trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $p = 8; @@ -187,15 +202,15 @@ oci_close($conn); ?> ]]> - - - - + + + + Using a PL/SQL stored procedure - - Using a stored procedure - + With stored procedures, you should bind variables for any arguments. + + ]]> - - - + +