Super simple phpmysql Database Query Class-PHP source code

Source: Internet
Author: User
This article provides you with a beautiful super simple phpmysql Database Query Class for free. This article provides you with a beautiful super simple php mysql DataBase Query Class for free.

Script ec (2); script

*/

Class Config {

Private $ host; // host name: generally localhost

Private $ root; // database tutorial account: usually root

Private $ password; // Database password: generally empty

Private $ datebase; // Database Name: custom

Private $ ut; // encoding issues such as: utf-8gbk

// Initialize the variables of this class
Function _ construct ($ host, $ root, $ password, $ datebase, $ ut ){

$ This-> host = $ host; // initialize the host Name

$ This-> root = $ root; // initialize the database account

$ This-> password = $ password; // initialize the Database password

$ This-> datebase = $ datebase; // initialize the Database Name

$ This-> conn (); // Method for initializing a database connection

$ This-> ut = $ ut; // initialize the Encoding
}

// Common Database Connection Methods
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 such database:". $ this-> datebase );

Mysql_query ("set names '$ this-> ut '");

}

// Common methods for transmitting SQL statements to the database
Function query ($ v ){

Return mysql_query ($ v );

}

// View data using common functions
Function fetch_row ($ query ){

Return mysql_fetch_row ($ query );

}

// Common error Methods
Function error (){

Return mysql_error ();

}

// Common methods for shutting down Databases
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.