一个php导出oracle库的php代码
作者:bea
<?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 fro
<?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>
<TR>
";foreach($keys as $key){ $table .= " <TH>$key</TH>
";}$table .= " </TR>
";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);?>第二种方法:
代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>sql check !</title>
<?
include $_SERVER['DOCUMENT_ROOT'] . "/_lib/common.lib.php";
ini_set('max_execution_time', 0);
if(!isset($a) || !isset($b)|| !isset($filename)){exit();}
for($i=$a;$i<$b;$i++)
{
$query = "select IDX,USER_ID,PASSWORD,NAME,SID1,SID2,PHONE,MOBILE,EMAIL,WORKPHONE from member where idx = $i";
$data = sql_fetch($query);
if ($data)
{
for ($ss=0; $ss<=count($data); $ss++)
{
$values .= "<td>".$data[$ss]."</td>";
}
}
fputs(fopen("$filename","a+"),"<table><tr>".$values."</tr></table>
");
unset($values);
}
?>
因为不会oracle,也是一行一行照抄来的,
数据库连接也没接触过,就直接用他自带的吧,
没用foreach 循环数组,很奇怪,总是输出2个重复的字段值,没办法就改用for了
qq:57112848 无名
有用 | 无用
$stmt = OCIParse($conn, $sql);OCIExecute($stmt);$rows = OCIFetchstatement($stmt,$results);$keys = array_keys($results);$table = "<table>
<TR>
";foreach($keys as $key){ $table .= " <TH>$key</TH>
";}$table .= " </TR>
";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);?>第二种方法:
代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>sql check !</title>
<?
include $_SERVER['DOCUMENT_ROOT'] . "/_lib/common.lib.php";
ini_set('max_execution_time', 0);
if(!isset($a) || !isset($b)|| !isset($filename)){exit();}
for($i=$a;$i<$b;$i++)
{
$query = "select IDX,USER_ID,PASSWORD,NAME,SID1,SID2,PHONE,MOBILE,EMAIL,WORKPHONE from member where idx = $i";
$data = sql_fetch($query);
if ($data)
{
for ($ss=0; $ss<=count($data); $ss++)
{
$values .= "<td>".$data[$ss]."</td>";
}
}
fputs(fopen("$filename","a+"),"<table><tr>".$values."</tr></table>
");
unset($values);
}
?>
因为不会oracle,也是一行一行照抄来的,
数据库连接也没接触过,就直接用他自带的吧,
没用foreach 循环数组,很奇怪,总是输出2个重复的字段值,没办法就改用for了
qq:57112848 无名
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- php结合飞信 免费天气预报短信
- PHP 身份证号验证函数
- php 购物车的例子
- PHP 错误之引号中使用变量
- PHP 字符串编码截取函数(兼容utf-8和gb2312)
- apache2.2.4+mysql5.0.77+php5.2.8安装精简
- PHP 读取文件的正确方法
- PHP session有效期问题
- PHP 判断常量,变量和函数是否存在
- PHP memcache扩展的三种安装方法
- PHP mb_convert_encoding 获取字符串编码类型实现代码
- php mssql 分页SQL语句优化 持续影响
- 配置Apache2.2+PHP5+CakePHP1.2+MySQL5运行环境
- mysql_fetch_row,mysql_fetch_array,mysql_fetch_assoc的区别
- PHP 危险函数解释 分析
- php反弹shell实现代码
- 将数组写入txt文件 var_export
- php 保留小数点
- PHP 中执行排序与 MySQL 中排序