·您的位置: 首页 » 资源教程 » 编程开发 » PHP » 新闻发布系统 (例子) 二 dbconn

新闻发布系统 (例子) 二 dbconn

类别: PHP教程  评论数:0 总得分:0
<?php


class CDBAbstract {
  var $_db_linkid = 0;
  var $_db_qresult = 0;
  var $RowData = array();
  var $NextRowNumber = 0;
  var $RowCount = 0;
  function CDBAbstract () {
    die ("CDBAbstract: Do not create instances of CDBAbstract! Use a subclass.");
  }
  function Open ($host, $user, $pass, $db = "") {
  }   
  function Close () {
  }
  function SelectDB ($dbname) {
  }   
  function Query ($querystr) {
  }
  function SeekRow ($row = 0) {
  }     
  function ReadRow () {
  }
  function _ident () {
    return "CDBAbstract/1.1";
  }
}

class CDBMySQL extends CDBAbstract {
  function CDBMySQL ($host, $user, $pass, $db = "") {
    $this->Open ($host, $user, $pass);
    if ($db != "")  
      $this->SelectDB($db);
  }   
  function Open ($host, $user, $pass) {
    $this->_db_linkid = mysql_connect ($host, $user, $pass);
  }   
  function Close () {
    @mysql_free_result($this->_db_qresult);
    return mysql_close ($this->_db_linkid);
  }   
  function SelectDB ($dbname) {
    if (@mysql_select_db ($dbname, $this->_db_linkid) == true) {
      return 1;     
    }  
    else {
      return 0;
    }    
  }    
  function  Query ($querystr) {
    $result = mysql_query ($querystr, $this->_db_linkid);
    if ($result == 0) {
      return 0;
    }  
    else {
      @mysql_free_result($this->_db_qresult);
      $this->RowData = array();       
      $this->_db_qresult = $result;
      $this->RowCount = @mysql_num_rows ($this->_db_qresult);
      if (!$this->RowCount) {
        // The query was probably an INSERT/REPLACE etc.
        $this->RowCount = 0;
      }  
      return 1;
    }
  }   
  function SeekRow ($row = 0) {
    if ((!mysql_data_seek ($this->_db_qresult, $row)) or ($row > $this->RowCount-1)) {
      printf ("SeekRow: Cannot seek to row %d/n", $row);
      return 0;
    }
    else {
      return 1;
    }
  }     
  function ReadRow () {
    if($this->RowData = mysql_fetch_array ($this->_db_qresult)) {
      $this->NextRowNumber++;
      return 1;
    }
    else {
      return 0;
    }
  }   
  function _ident () {
    return "CDBMySQL/1.1";
  }   
}

?> 


-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1