给你一个自写的函数吧 我在oracle816下一直用的这个 hope that helpsfunction exec_query($qry_sql)
{ //提交SQL语句 select 语句专用
global $conn;
$rst=array();
if (!($cursor= OCINewCursor($conn)))
{
echo "错误: 游标打开失败 ";
exit;
}
//echo $qry_sql;
$stmt = OCIParse($conn,$qry_sql);//预试SQL conn为连接参数
if (!@OCIExecute($stmt)) {return false;}//执行
$i=0;
$numCols=OCIFetchStatement($stmt,$cursor);//将数据放入$cursor,返回记录数放入$numCols
if ( $numCols>0 )
{
// 遍历结果集
for ($j=0;$j<$numCols;$j++)
{
reset($cursor);
while ( $column = each($cursor) ) //循环取出每条记录
{
//$column 中包含四个偏移量 分别是 1,value,0,key 呵呵 ^_^
$data = $column['value'];
$rst[$j][$i] = $data[$j];
$rst[$j][$column['key']] = $data[$j];
$i++;
}
$i=0;
}
return $rst;
}
return false;
//END of exec_query($qry_sql)
}$Query_String="select * from ctxsys.mytest";
$rst=exec_query($Query_String);
$rst[0]['name'] 就是第一条记录的name字段值了 呵呵
{ //提交SQL语句 select 语句专用
global $conn;
$rst=array();
if (!($cursor= OCINewCursor($conn)))
{
echo "错误: 游标打开失败 ";
exit;
}
//echo $qry_sql;
$stmt = OCIParse($conn,$qry_sql);//预试SQL conn为连接参数
if (!@OCIExecute($stmt)) {return false;}//执行
$i=0;
$numCols=OCIFetchStatement($stmt,$cursor);//将数据放入$cursor,返回记录数放入$numCols
if ( $numCols>0 )
{
// 遍历结果集
for ($j=0;$j<$numCols;$j++)
{
reset($cursor);
while ( $column = each($cursor) ) //循环取出每条记录
{
//$column 中包含四个偏移量 分别是 1,value,0,key 呵呵 ^_^
$data = $column['value'];
$rst[$j][$i] = $data[$j];
$rst[$j][$column['key']] = $data[$j];
$i++;
}
$i=0;
}
return $rst;
}
return false;
//END of exec_query($qry_sql)
}$Query_String="select * from ctxsys.mytest";
$rst=exec_query($Query_String);
$rst[0]['name'] 就是第一条记录的name字段值了 呵呵
<?php
$conn = OCILogon("system","sa","local");
$stmt = OCIParse($conn,"select * from ctxsys.mytest");
/* 使用 OCIDefineByName 要在执行 OCIExecute 前 */
OCIDefineByName($stmt,"NAME",&$name);
OCIExecute($stmt);
while (OCIFetch($stmt)) {
echo "name:".$name."\n";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
?>