Super simple PHP MySQL database query class

Source: Internet
Author: User

<?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 ();

}

}

?>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.