Home > Backend Development > PHP Tutorial > php mssql database connection code (1/2)_PHP tutorial

php mssql database connection code (1/2)_PHP tutorial

WBOY
Release: 2016-07-13 17:04:15
Original
957 people have browsed it

php教程 mssql 数据库教程连接类代码

class DB_Sql {
  var $Host     = "";
  var $Database = "";
  var $User     = "";
  var $Password = "";

  var $Link_ID  = 0;
  var $Query_ID = 0;
  var $Record   = array();
  var $Row      = 0;
 
  var $Errno    = 0;
  var $Error    = "";

  var $Auto_Free = 0;     ## set this to 1 to automatically free results
 
 
  /* public: constructorwww.bKjia.c0m */
  function DB_Sql($query = "") {
      $this->query($query);
  }

  function connect() {
    if ( 0 == $this->Link_ID ) {
      $this->Link_ID=mssql_connect($this->Host, $this->User, $this->Password);
      if (!$this->Link_ID)
        $this->halt("Link-ID == false, mssql_pconnect failed");
      else
          @mssql_select_db($this->Database, $this->Link_ID);
    }
  }
  function free_result(){
      mssql_free_result($this->Query_ID);
      $this->Query_ID = 0;
  }
 
  function query($Query_String)
  {
   
    /* No empty queries, please, since PHP4 chokes on them. */
    if ($Query_String == "")
      /* The empty query string is passed on from the constructor,
       * when calling the class without a query, e.g. in situations
       * like these: '$db = new DB_Sql_Subclass;'
       */
      return 0;

      if (!$this->Link_ID)
        $this->connect();
   
#   printf("
Debug: query = %s
n", $Query_String);

1 2

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630858.htmlTechArticlephp教程 mssql 数据库教程连接类代码 class DB_Sql { var $Host = ; var $Database = ; var $User = ; var $Password = ; var $Link_ID = 0; var $Query_ID = 0; var $Record = arr...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template