Home >Backend Development >PHP Tutorial >如何在PHP中使用Oracle数据库(2)_php基础

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

WBOY
WBOYOriginal
2016-05-17 09:48:01738browse

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.  

Statement:
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