<?php Tutorial
*/
Class config{
Private $host; Host name: usually localhost
Private $root; Database Tutorial account: typically root
Private $password; Database password: generally null
Private $datebase; Database name: General own definition
Private $ut; Coding issues such as: UTF-8GBK
Initializes a variable of this class
function __construct ($host, $root, $password, $datebase, $ut) {
$this->host= $host; Initialize host name
$this->root= $root; Initializing the Database account number
$this->password= $password; Initializing the database password
$this->datebase= $datebase; Initializing database name
$this->conn (); How to initialize the connection database
$this->ut= $ut; Initialize encoding
}
Common methods of connecting databases
Function Conn () {
$conn = MySQL Tutorial _connect ($this->host, $this->root, $this->password) or Die ($this->error ());
mysql_select_db ($this->datebase, $conn) or Die ("No This database:". $this->datebase);
mysql_query ("SET NAMES ' $this->ut '");
}
Common methods for transferring SQL to a database
function query ($v) {
return mysql_query ($v);
}
Common functions View data
function Fetch_row ($query) {
Return mysql_fetch_row ($query);
}
Common methods of error
Function error () {
return Mysql_error ();
}
Common methods for shutting down a database
function Close () {
return Mysql_close ();
}
}
?>