1.以前連mysql的語法如下
$link_id=@mysql_connect($dbhost,$dbuser,$dbpassword);
$query="SELECT userid,password,email FROM $admin_table WHERE userid='$admin_name'";
$result=mysql_query($query);
$admin_data=mysql_fetch_array($result);
-------------------------------------
2.Oracle如下
$user=mis1,$password=dbmis95,$myservice=timlong
$conn = ocilogon($user,$password,$myservice);//取得連線
可以對照著看 我將mysql語法 改成oci的連線方式
$query="SELECT count(*) AS total_entries FROM $posts_table";
//$result=mysql_query($query);
$statement = oci_parse ($conn, $query);//接收$conn參數、所下的query
oci_execute($statement);//真正去執行
$total_entries=oci_num_rows($statement);//取得查詢記錄的筆數
http://tw.php.net/manual/tw/function.oci-num-rows.php
針對資料運作
//$row=mysql_fetch_array($result);
//$total_entries=$row['total_entries']; // total number of guestbook entries
oci_fetch_array
oci_fetch_array -- Returns the next row from the result data as an associative or numeric array, or both
這也就是我們可以利用一個while迴圈來跑所有的查詢資料
http://tw.php.net/manual/tw/function.oci-fetch-array.php (OCI_BOTH 效果如下)我們可以用0取出第一列資料的第一個欄位亦用用欄位名稱來取出
while ( $row = oci_fetch_array ( $statement , OCI_BOTH )) {
echo $row [ 0 ]. " and " . $row [ 'ID' ]. " is the same<br>" ;
echo $row [ 1 ]. " and " . $row [ 'NAME' ]. " is the same<br>" ;
}