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.