Teach you how to use Oracle database in PHP (2)
Create A Table Using OCI
Next we will create an email personal information book. This time OCI8 API instructions are used
Related php code:
PutEnv("Oracle_SID=ORASID");
$connection = OCILogon ("username", "passWord");
if ($connection == false){
echo OCIError($connection)."
";
exit;
}
$query = "create table email_info " .
"(fullname varchar(255), email_address varchar(255))";
$cursor = OCiparse ($connection, $query);
if ($cursor == false){
echo OCIError($cursor)."
";
exit;
}
$result = OCIExecute ($cursor);
if ($result == false){
echo OCIError($cursor)."
";
exit;
}
OCICommit ($connection);
OCILogoff ($connection);
?>
We can see that the syntax of these two pieces of code is almost the same, the only difference is the function name; secondly, in OCI8 we do not need to specifically run the instruction to open the cursor, the system automatically returns a cursor ID when calling OCIParse.
The above has introduced how to use Oracle database in PHP (Part 2), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.