正 文

MYSQL的操作类(已封装)


www.7dspace.com  更新日期:2005-11-3 6:57:54  七度空间


    //得到指定行的指定列的值,返回字符串
    //如果不指定Offset将取得下一行的值
    //如果不指定nFields将取得该行的值,并已数组形式返回
    function GetValue($nFields=-1,$Offset=-1)
    {
      if($this->nResult==-1)
      {
        $this->nErr=1;
        $this->sErr="GetValue:请先执行Query()函数!";
        return;
      }
      if($Offset>-1)
      {
                $this->nOffset=$Offset;
        if($this->nOffset>=$this->nRows)
        {
          $this->nErr=1;
          $this->sErr="GetValue:所要求的偏移量太大,无法达到!";
          return;
        }
      }
           if(!@mysql_data_seek($this->nResult,$this->nOffset))
                {
                  $this->nErr=1;
                  $this->sErr="GetValue:请求不存在的记录!";
                  return;
                }
      $aResult=mysql_fetch_row($this->nResult);
      if(is_int($nFields)&&$nFields>-1)
      {
        if($nFileds>$this->nCols)
        {
          $this->nErr=1;
          $this->sErr="GetValue:所请求的列值大于实际的列值!";
          return;
        }
        return $aResult[$nFields];
      }
          if(is_string($nFields))
          {
                $nFields=strtolower($nFields);
            for($i=0;$i<$this->nCols;$i++)
                {
                  if($this->aFName[$i]==$nFields)
                          break;
                }
                if($i==$this->nCols)
                  {
                        $this->nErr=1;
                        $this->sErr="GetValue:所请求的列不存在,请仔细检查!";
                        return;
                  }
                  return $aResult[$i];
          }
      return $aResult;
    }
6页,页码:[1] [2] [3] [4] [5] [6] 

上一篇:使用XML-RPC来访问Web服务
下一篇:Windows系统自动保存密码再现
作者:熊毅(小熊)  来源:CSDN ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐