Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Oracle with PHP Jump to:  
Category: >> Oracle PL/SQL >> Oracle with PHP Bookmark and Share

<< 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);
 
?>
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 300 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?