Quick Search:
 
 Oracle PL/SQL: Oracle with PHP Jump to:  
Category: >> Oracle PL/SQL >> Oracle with PHP  

<< lastnext >>

Snippet Name: Oracle with PHP

Description: The following example demonstrates how data can be SELECTed and manipulated via INSERT, UPDATE and DELETE statements:

Comment: (none)

Language: PHP, ORACLE
Highlight Mode: PLSQL
Last Modified: February 27th, 2009

<?php
 
$c=OCILogon("scott", "tiger", "orcl");
IF ( ! $c ) {
 echo "Unable to connect: " . var_dump( OCIError() );
 die();
}
 
// DROP old TABLE...
$s = OCIParse($c, "drop table tab1");
OCIExecute($s, OCI_DEFAULT);
 
// CREATE NEW TABLE...
$s = OCIParse($c, "create table tab1 (col1 number, col2 varchar2(30))");
OCIExecute($s, OCI_DEFAULT);
 
// INSERT data INTO TABLE...
$s = OCIParse($c, "insert into tab1 values (1, 'Frank')");
OCIExecute($s, OCI_DEFAULT);
 
// INSERT data using bind variables...
$var1 = 2;
$var2 = "Scott";
$s = OCIParse($c, "insert into tab1 values (:bind1, :bind2)");
OCIBindByName($s, ":bind1", $var1);
OCIBindByName($s, ":bind2", $var2);
OCIExecute($s, OCI_DEFAULT);
 
// SELECT Data...
$s = OCIParse($c, "select * from tab1");
OCIExecute($s, OCI_DEFAULT);
WHILE (OCIFetch($s)) {
 echo "COL1=" . ociresult($s, "COL1") .
    ", COL2=" . ociresult($s, "COL2") . "n";
}
 
// COMMIT TO save changes...
OCICommit($c);
 
// Logoff FROM Oracle...
OCILogoff($c);
 
?>
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org