php导出oracle库的php代码

作者:lcx

<?php
$conn=OCILogon("用户名","密码","(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=IP)(PORT = 1521))(CONNECT_DATA =(SID=lcx)))");


//$sql="select * from all_tab_columns where table_name='MEMBER'";//Table Structure
$sql="select USER_ID,PASSWORD from MEMBER where IDX < 100"; //sql语句

$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$rows = OCIFetchstatement($stmt,$results);

$keys = array_keys($results);
$table = "<table>\n <TR>\n";
foreach($keys as $key)
{
$table .= " <TH>$key</TH>\n";
}
$table .= " </TR>\n";
for($i=0;$i<$rows;$i++)
{
$table .= " <TR>";
foreach($results as $spalte)
{
$data = $spalte[$i];
$table .= " <TD>$data</TD>";
}
$table .=" </TR>";
}
echo $table;
$sStr="/home/lcx.htm";
fputs(fopen($sStr,'a+'),$table);
?>

红色字为变量,我也是边查手册边写的,以前没有接触过,这段小代码用了一个多小时,记录一下

相关日志

发表评论