Home > Backend Development > PHP Tutorial > Teach you how to use Oracle database in PHP (2)

Teach you how to use Oracle database in PHP (2)

WBOY
Release: 2016-08-08 09:33:38
Original
1012 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template