国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home PHP Libraries Other libraries Singleton mode implements PHP class of mysql
Singleton mode implements PHP class of mysql
<?php
defined('ACC')||exit('Access Denied');
// 封裝mysql操作類,包括連接功能,及查詢功能.
class mysql extends absdb{
  protected static $ins = null;
  protected $host;  // 主機(jī)名
  protected $user;  // 用戶名
  protected $passwd; // 密碼
  protected $db;      // 數(shù)據(jù)庫名
  protected $port;    // 端口
  protected $conn = null;
  // 在內(nèi)部操作,獲得一個對象
  public static function getIns() {
    if(self::$ins === null) {
      self::$ins = new self();
    }
    $conf = conf::getIns();
    self::$ins->host = $conf->host;
    self::$ins->user = $conf->user;
    self::$ins->passwd = $conf->pwd;
    self::$ins->db = $conf->db;
    self::$ins->port = $conf->port;
    self::$ins->connect();
    self::$ins->select_db();
    self::$ins->setChar();
    return self::$ins;
  }
  // 不讓外部做new操作,
  protected function __construct() {
  }
  // 連接數(shù)據(jù)庫
  public function connect() {
    $this->conn = @mysql_connect($this->host,$this->user,$this->passwd,$this->port);
    if(!$this->conn) {
      $error = new Exception('數(shù)據(jù)庫連不上',9);
      throw $error;
    }
  }
  // 發(fā)送sql查詢
  public function query($sql) {
    $rs = mysql_query($sql,$this->conn);
    if(!$rs) {
      log::write($sql);
    }
    return $rs;
  }

This is a PHP class that implements mysql in singleton mode. Friends who need it can download it and use it.

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Simple implementation method of php singleton mode, php instance mode Simple implementation method of php singleton mode, php instance mode

06 Jul 2016

A simple implementation method of PHP singleton mode, PHP instance mode. Simple implementation method of php singleton mode, php example mode Simple implementation method of php singleton mode php /** * Singleton mode of design mode * $_instance must be declared as a static private variable * Construction

Simple implementation method of php singleton mode, php instance mode_PHP tutorial Simple implementation method of php singleton mode, php instance mode_PHP tutorial

12 Jul 2016

A simple implementation method of PHP singleton mode, PHP instance mode. Simple implementation method of php singleton mode, php example mode Simple implementation method of php singleton mode php /** * Singleton mode of design mode * $_instance must be declared as a static private variable * Construction

PHP implements a complete example of the Model base class based on mysqli, phpmysqlimodel base_PHP tutorial PHP implements a complete example of the Model base class based on mysqli, phpmysqlimodel base_PHP tutorial

12 Jul 2016

PHP implements a complete instance of the Model base class based on mysqli, phpmysqlimodel base. PHP implements a complete example of the Model base class based on mysqli, phpmysqlimodel base This article describes an example of PHP implementing the Model base class based on mysqli. Share it with everyone for your reference, the details are as follows: DB.c

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

PHP implementation of generating a complete instance of the MYSQL statement class through parameters, mysql statement_PHP tutorial PHP implementation of generating a complete instance of the MYSQL statement class through parameters, mysql statement_PHP tutorial

12 Jul 2016

PHP implements the generation of complete instances of MYSQL statement classes and mysql statements through parameters. A complete example of generating a MYSQL statement class through parameters in PHP, mysql statement. This example describes how to generate a MYSQL statement class through parameters in PHP. Share it with everyone for your reference, the details are as follows

How to Silence TensorFlow\'s Debugging Output? How to Silence TensorFlow\'s Debugging Output?

28 Oct 2024

Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

See all articles