The order that you need is:
- Define your connection (OCILogon);
- Define and parse your query (OCI_PARSE);
- Execute the parsed statement (OCI_EXECUTE);
- Close the connection (OCILogoff);
An example for insertion into the Oracle test database is:
<?php
PutEnv("ORACLE_SID=home");
echo "Have set the Oracle SID<BR>\n";
$connection = OCILogon ("scott", "tiger");
echo "Have established the connection";
if ($connection == false){
echo "Sorry , connection failed";
echo OCIError($connection)."<BR>\n";
exit;
}
#$query = "select * from emp";
$query = "INSERT INTO emp (empno, ename, job, sal, comm, deptno) VALUES (7890, 'JINKS', 'CLERK', 1.2E3, NULL, 40)";
$cursor = OCIParse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."<BR>\n";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."<BR>";
exit;
}
echo "Have successfully inserted a row<BR>\n";
OCILogoff ($connection);
?>
HTH
Justin