注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发PHP → 文章内容

PHP中使用类对数据库进行操作

作者:佚名 来源:不详 发布时间:2007-11-29 20:52:12

  function query_id() {
   return $this->Query_ID;
   }
  
   /* 连接处理 */
   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;
  
   /* 建立连接,选择数据库 */
   if ( 0 == $this->Link_ID ) {
  
   $this->Link_ID=mysql_pconnect($Host, $User, $Password);
   if (!$this->Link_ID) {
   $this->halt("pconnect($Host, $User, \$Password) failed.");
   return 0;
   }
  
   if (!@mysql_select_db($Database,$this->Link_ID)) {
   $this->halt("cannot use database ".$this->Database);
   return 0;
   }
   }
  
   return $this->Link_ID;
   }
  
   /* 丢弃查询结果,释放占用的内存 */
   function free() {
   @mysql_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->connect()) {
   return 0; /* we already complained in connect() about that. */
   };
  
   # New query, discard previous result.
   if ($this->Query_ID) {
   $this->free();
   }
更多内容请看PCdog.com--PHP与数据库  数据库相关文章专题
上一页  [1] [2] [3] [4] [5] [6] [7]  下一页


  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved