USE Oracle / oci8 with PHP / test sample code

前提環境要先裝好 Oracle instant client , 然後 PHP 要把 instantclient 編譯進去

–with-oci8=instantclient,/usr/lib/oracle/10.2.0.3/client/lib

這是 sample code

$conn = OCILogon('scott', 'scott', '//172.30.0.176/DB1');

$query = 'select * from dept';

$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
  foreach ($row as $item) {
    echo $item." ";
  }
  echo "\n";
}

OCILogoff($conn);


1. 建 oracle table 時不管key 的 table name , field name 是否為小寫, 在 oracle 都顯示成大寫
2. 用 PHP 的 OCI functions 下的 SQL command 也可以不管大小寫