Oracle PHP Select, Insert, Update and Delete Query
December 2nd, 2008
Most of you know that in the previous post I wrote about PHP and oracle stored procedure. and I also wrote about PHP and Oracle unlock system account. Now I want to give you an example of PHP Select, Insert, Update and Delete Query.
This post will be straightforward. A knowledge of basic PHP and oracle is required. Just follow the comments
<?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);
?>
Nah, that’s all that you will need about PHP and Oracle query. I copied it from OracleFAQ. If you want to learn more, you can visit it.
Here are interesting links about Oracle I found.
- Exception – ORA-00604: error occurred at recursive SQL level 1 ORA-01003: no statement parsed
- Find Last Day of Month in PHP
- Browser Rider – Exploit your browser!
- How PHP Connect to Oracle: Oracle Connection String

Gautam Categories: Programming Databases, FAQs Help and Tutorials, Languages, Oracle, PHP, Programming, Select, Stored procedure
Recent Comments