PHP訪問Oracle資料庫

2022-03-12 22:58:40 字數 588 閱讀 6647

說明:

oracle資料庫帳號:stic

oracle資料庫密碼:stic

oracle資料庫例項:orcl

oracle資料庫表:userinfo

oracle表的列:id,name

不處理異常的**如下:

//建立資料庫連線

//

建立資料庫連線

$conn = oci_connect("stic", "stic", "orcl");

//定義sql語句

$sql = "select * from stic.userinfo";

//判斷連線是否成功

if ($conn

) else

//關聯查詢語句和資料庫連線

$stid = oci_parse($conn, $sql

);//

執行查詢

oci_execute($stid,oci_default);

//迴圈輸出資料,php中的"."代表兩個字串相加

while ($row = oci_fetch_array($stid,oci_return_nulls))

PHP訪問資料庫

在php中,無論訪問哪種資料庫,都需要使用sql。php最適合與mysql資料庫配合使用,主要原因是php提供了很多操作mysql資料庫的內建函式,可方便地實現訪問和操作mysql資料庫的各種需要。php訪問mysql資料庫的具體步驟 1 建立與mysql伺服器的連線 2 設定字符集 3 選擇要操作...

php訪問資料庫

1.建立資料庫 lyb create database lyb create table lyb1 id int not null auto increment title varchar 200 not null content text not null author varchar 30 no...

PHP 資料庫訪問

一 過時方法 設定頁面編碼格式 header content type text html charset utf 8 1 生成鏈結 db connect mysql connect localhost root 517 localhost 伺服器的位址 root 資料庫的使用者名稱 517 資料庫...