给你一个自写的函数吧  我在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字段值了 呵呵

解决方案 »

  1.   

    我不是这个意思。用ora_getcolumn($cursor,0)我会的,但我有30几个字段,我要显示较后面的字段,我还要数,他是第几个。能不能想asp那样,用字段名字直接用,而不要数数啊。
      

  2.   

    如果是用oci就可以,就用
    <?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);
    ?>