<?php <b>●Oracleとの接続テスト</b> <hr> <?php // Oracleとの接続 $conn = OCILogon("scott", "tiger", "dbserver:1521/orcl"); // SQL文のparse $stmt = OCIParse($conn,"select * from emp "); // SQL文の実行 OCIExecute($stmt); $ncols = OCINumCols($stmt); echo "<TABLE BORDER='1'>"; echo "<TR>"; for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); echo "<TH>" . $column_name . "</TH>"; } echo "</TR>"; // データのFetch while(OCIFetch($stmt)) { echo "<TR>"; for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); // データの表示 echo "<TD>" . OCIResult($stmt, $column_name) . "</TD>"; } echo "</TR>"; } echo "</TABLE>"; // リソースの解放 OCIFreeStatement($stmt); // Oracleから切断 OCILogoff($conn); ?>