PHP连接并输出oracle数据

这几天处理PHP与Oracle的问题。在PHP中链接并输出oracle数据,下面为一个示例程序:

PHP语言: PHP连接输出oracle数据
$sid=”(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=water)))”;
$DBCONN = ocilogon(water,water,$sid);
if($DBCONN)
{
$sql=’select * from ‘.TB_PREFIX.’CUSTOMER’;
$result = ociparse ($DBCONN, $sql);
OCIExecute($result);
$nrows = OCIFetchStatement($result, $results);
if ($nrows > 0) {
echo “<table border=\”1\”>\n”;
echo “<tr>\n”;
while (list($key, $val) = each($results)) {
echo “<th>$key</th>\n”;
}
echo “</tr>\n”;

for ($i = 0; $i < $nrows; $i++) {
reset($results);
echo “<tr>\n”;
while ($column = each($results)) {
$data = $column['value'];
echo “<td>$data[$i]</td>\n”;
}
echo “</tr>\n”;
}
echo “</table>\n”;
} else {
echo “No data found<br />\n”;
}
echo “$nrows Records Selected<br />\n”;

OCIFreeStatement($result);
OCILogoff($DBCONN);
}
else
{
echo ‘false’;
}

相关文章: 

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

还没有评论。

发表评论

(必填)

(必填)