Class Mysqlconn {Defines a private static property that is used to hold an instantiated objectprivate static $dbcon;Defines a private static property that is used to connect to a databaseprivate static $conn;Define a private destructor to connect to
I used PHP to encapsulate a mysql class in the DB database.
Conn = mysql_connect (DB_HOST, DB_USER, DB_PASS) or die ("connect failed ". mysql_error (); // select the database mysql_select_db (DB_DATABASENAME, $ this-> conn); // SET the encoding
Configuration Files Section
Class
conn = new mysqli ($host, $username, $passwd); $this->selectdb ($dbname); $this->coding ($COD); }//Set the encoding format public function coding ($cod) {mysql_query ("set CHARACTER set". $cod);
PHP encapsulates a database mysql class
// Configure the database
Define ('Db _ host', '127. 0.0.1 '); // server address
Define ('Db _ user', 'root'); // USER name
The examples in this article describe the connection MySQL class and usage in PHP encapsulation. Share to everyone for your reference, specific as follows:
Class mysql{Private $db _name, private $db _host, private $db _user, private $db _pwd,
Data access is divided into three types of 1. Use a function to discard 2 in a new version. An object-oriented approach to the Mysqli class 3.PDO example codename name gender National Birthdays Use the Mysqli class to access the
After downloading the ecshop, unzip, go to the directory upload/includes, copy the cls_mysql.php into your own websiteLike my directory structure.Classes/classes/cls_mysql. php/classes/connfig. PHP/index.phpCreate a new connfig.php file in
This article describes the PHP implementation with read and write separation function of the MySQL class. Share to everyone for your reference, specific as follows:
Overview:
1. According to the SQL statement to determine whether to connect read
MySQL;?
# All text and code within this file are (c) opyright
# Pangolin Software Limited 2000.
#
# You'll edit this file to customise it for your web-site,
# However, the actual source code may is altered in
# any way without the prior written
Requirements:1. Object has ID, host, port three properties2. Define tool create_id, randomly generate ID for each object at instantiation, guarantee ID unique3. Provide two kinds of instantiation mode, one: User incoming host and port mode two: Read
& Amp; nbsp; very complete PHP MySQL operation class, even if PDO, ActiveRecord, ORM, Framework, Framework... It is not as powerful and easy to use as it is, and you won't
Very complete PHP MySQL operation class, even if PDO, ActiveRecord, ORM,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.