Home PHP Libraries Other libraries Mysql's complete database connection PHP class library
Mysql's complete database connection PHP class library
<?php
class mysql {
public function __construct($db_host, $db_user, $db_pwd, $db_database, $conn, $coding) {
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_pwd = $db_pwd;
$this->db_database = $db_database;
$this->conn = $conn;
$this->coding = $coding;
$this->connect();
}
/*数据库连接*/
public function connect() {
if ($this->conn == "pconn") {
//永久链接
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
//即使链接
$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}
if (!mysql_select_db($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error("数据库不可用:", $this->db_database);
}
}

private $db_host; //Database host

private $db_user; //Database username

private $db_pwd; //Database username and password

private $db_database; //Database name

private $conn; //Database connection identification;

private $result; //Result identification of query command execution

private $ sql; //sql execution statement

private $row; //number of entries returned

private $coding; //database encoding, gbk, utf8, gb2312

private $bulletin = true; //Whether to enable error logging

private $show_error = false; //In the testing phase, all errors are displayed, which has security risks and is closed by default

private $is_error = false; //Whether to terminate immediately when an error is detected, the default is true, it is recommended not to enable it, because it is very distressing for users to not see anything when there is a problem


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

PHP implements a relatively complete database operation class PHP implements a relatively complete database operation class

27 Dec 2016

This article mainly introduces PHP to implement a relatively complete database operation class, which can implement basic database connections, execute SQL statements, error prompts and other related skills. Friends in need can refer to it.

Complete example explanation of mongoDB database operation class implemented in PHP Complete example explanation of mongoDB database operation class implemented in PHP

27 Jun 2018

This article mainly introduces the mongoDB database operation class implemented by PHP. It combines the complete example form with a detailed analysis of PHP's implementation techniques for mongoDB database connection, addition, deletion, modification, statistics and other operations based on the singleton mode. Friends in need can refer to the following

asp.net database connection integrates the previous PHP database connection class~~ to make a paging class! asp.net database connection integrates the previous PHP database connection class~~ to make a paging class!

29 Jul 2016

asp.net database connection: asp.net database connection integrates the previous PHP database connection class~~ to make a paging class!: I don’t know if there is a future for learning PHP~ The more I write, the more boring it becomes <?php Class createdb //Class Start { var $db= "localhost";//Database address; var $dbname = "root";//User name; var $dbpwd = "";//Password; var $dbtable = "mysql";//Use Database var $conn; //Database connection;

Complete PHP operation MySQL database class Complete PHP operation MySQL database class

25 Jul 2016

Complete PHP operation MySQL database class

php mysql complete database connection class_PHP tutorial php mysql complete database connection class_PHP tutorial

13 Jul 2016

PHP mysql complete database connection class. php tutorial mysql tutorial complete database tutorial connection class */ class mysql { private $db_host; //database host private $db_user; //database user name private $db_pwd; //database user name password

Tips on using PHP database connection function library Tips on using PHP database connection function library

15 Jun 2023

With the continuous development of Internet technology, PHP, as an important server-side scripting language, has been widely used. In WEB application development, the use of databases is very common. Connecting to the database is the first step in PHP development. Here are some tips for using the PHP database connection function library. 1. MYSQLI extension library The MYSQLI extension library is only available after the PHP5 version. It is more optimized and stable than the previous MYSQL extension library. The MYSQLI extension library provides a more powerful and convenient

See all articles