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