正 文

MYSQL的操作类(已封装)


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


    function AddNew($TableName="")  //标志开始添加数据
    {
      $this->Initialize();
      if(!empty($TableName))
        $this->sTName=$TableName;
      if($this->NewEdit>0)
      {
        $this->nErr=1;
        $this->sErr="AddNew:你正在对数据库进行添加或更新操作!";
        return;
      }
      if(empty($this->sTName))
      {
        $this->nErr=1;
        $this->sErr="AddNew:想要添加的数据库表为空,可以在构造时指定,也可在AddNew()时指定!";
        return;
      }
      unset($this->aNew);
      $this->aNew=array();
      $this->NewEdit=1;
      $strSQL="select * from ".$this->sTName;
          $this->sSQL=$strSQL;
      if(!$this->nResult=mysql_query($strSQL))
      {
        $this->nErr=1;
        $this->sErr="AddNew:SQL语句:".strSQL."<br><br>MySql错误:".mysql_error();
        return;
      }
      $this->nCols=mysql_num_fields($this->nResult);
      unset($this->aFName);
      $this->aFName=array();
      for($i=0;$i<$this->nCols;$i++)
         $this->aFName[$i]=strtolower(mysql_field_name($this->nResult,$i));
    }

    function Edit($Condition="",$TableName="")  //对指定数据库表进行编辑
    {
                  $this->Initialize();
                  if(!empty($TableName))
                          $this->sTName=$TableName;
                  $this->sEditCon=$Condition;
                  if(empty($this->sTName))
                  {
                          $this->nErr=1;
                          $this->sErr="Edit:在编辑前请先指定数据库表!";
                          return;
                  }
                  unset($this->aNew);
                  $this->aNew=array();
                  $this->NewEdit=2;
                  $strSQL="select * from ".$this->sTName;
                  $this->sSQL=$strSQL;
                  if(!$this->nResult=mysql_query($strSQL))
          {
             $this->nErr=1;
             $this->sErr="Edit:SQL语句:".strSQL."<br><br>MySql错误:".mysql_error();
             return;
          }
          $this->nCols=mysql_num_fields($this->nResult);
          unset($this->aFName);
          $this->aFName=array();
          for($i=0;$i<$this->nCols;$i++)
             $this->aFName[$i]=strtolower(mysql_field_name($this->nResult,$i));
    }

6页,页码:[1] [2] [3] [4] [5] [6] 

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

热 点 导 读
特 别 推 荐