当前位置:首页>网络学院>程序开发>PHP教程>文章内容

在PHPLIB中的MYSQL类中加INSERT,UPDATE,DELETE等函数

[ 来源:www.it55.com | 作者: | 时间:2007-07-13 | 收藏 | 推荐 ] 【

<?php
/*
 * Session Management for PHP3
 *
 * Copyright (c) 1998-2000 NetUSE AG
 *                    Boris Erdmann, Kristian Koehntopp
 *
 * $Id: db_mysql.inc,v 1.2 2000/07/12 18:22:34 kk Exp $
 *
 */ it55.com

class DB_Sql {
 
  /* public: connection parameters */
  var $Host     = "";
  var $Database = "";
  var $User     = "";
  var $Password = ""; 免费资源www.it55.com

  /* public: configuration parameters */
  var $Auto_Free     = 0;     ## Set to 1 for automatic mysql_free_result()
  var $Debug         = 0;     ## Set to 1 for debugging messages.
  var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
  var $Seq_Table     = "db_sequence";

vd;k;l www.it55.com rdfg

  /* public: result array and current row number */
  var $Record   = array();
  var $Row;

www.it55.com

  /* public: current error number and error text */
  var $Errno    = 0;
  var $Error    = ""; www.it55.com在线教程

  /* public: this is an api revision, not a CVS revision. */
  var $type     = "mysql";
  var $revision = "1.2";

sflj www.it55.com kg^&fgd

  /* private: link and query handles */
  var $Link_ID  = 0;
  var $Query_ID = 0;
 
  var $sql = "";

it55.com

  /* public: constructor */
  function DB_Sql($query = "") {
      $this->query($query);
  }

it55.com

  /* public: some trivial reporting */
  function link_id() {
    return $this->Link_ID;
  } www.it55.com在线教程

  function query_id() {
    return $this->Query_ID;
  } vd;k;l www.it55.com rdfg

  /* public: connection management */
  function connect($Database = "", $Host = "", $User = "", $Password = "") {
    /* Handle defaults */
    if ("" == $Database)
      $Database = $this->Database;
    if ("" == $Host)
      $Host     = $this->Host;
    if ("" == $User)
      $User     = $this->User;
    if ("" == $Password)
      $Password = $this->Password;
     
    /* establish connection, select database */
    if ( 0 == $this->Link_ID ) {
   
      $this->Link_ID=mysql_pconnect($Host, $User, $Password);
      if (!$this->Link_ID) {
        $this->halt("pconnect($Host, $User, \$Password) failed."); it55.com
        return 0;
      }

www.it55.com

      if (!@mysql_select_db($Database,$this->Link_ID)) {
        $this->halt("cannot use database ".$this->Database);
        return 0;
      }
    }
   
    return $this->Link_ID;
  }

http://www.it55.com/

  /* public: discard the query result */
  function free() {
      @mysql_free_result($this->Query_ID);
      $this->Query_ID = 0;
  } IT资讯之家 www.it55.com

  /* public: perform a query */
  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;

免费资源www.it55.com

    if (!$this->connect()) {
      return 0; /* we already complained in connect() about that. */
    }; 45398 www.it55.com it55学习IT知识,享受IT生活 4dfkjn

    # New query, discard previous result.
    if ($this->Query_ID) {
      $this->free();
    }

http://www.it55.com/

    if ($this->Debug)
      printf("Debug: query = %s<br>\n", $Query_String); vd;k;l www.it55.com rdfg

    $this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
    $this->Row   = 0;

(编辑:IT资讯之家 www.it55.com

返回顶部
共5页: 上一页 1 [2] [3] [4] [5] 下一页  

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]

图片文章