Home > php教程 > php手册 > body text

如何在PHP中使用Oracle数据库(2)

WBOY
Release: 2016-06-13 12:41:04
Original
1061 people have browsed it

Create A Table Using OCI

下面我们将建立一个email个人信息簿。这次采用OCI8 API指令  

相关PHP代码:


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

?>  


我们可以看到这2段代码语法几乎都一样,区别仅仅函数名字不同; 其次,在OCI8中我们不需要专门运行打开游标的指令,在调用 OCIParse 系统就自动返回了一个游标ID.  

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!