Php connection to mysql database class. Php connection to mysql database class this is a simple and practical php connection to mysql database class, only data query, returned array set, obtain the new id, obtain the record row, and other simple mysql database php connection mysql database class. this is a simple and practical php connection to the mysql database class. it only performs data queries and returns the array set, obtain the new id, obtain the record line, and other simple mysql database connection code.
Php Tutorial connection to mysql tutorial database tutorial class
This is a simple and practical php connection to the mysql database class. it only performs data queries, returns array sets, obtains new IDs, obtains record rows, and other simple mysql database connection code.
*/
Class database {
Var $ dblink;
Function connect ($ dbhost, $ dbuser, $ dbpw, $ dbname = ""){
$ This-> dblink = mysql_connect ($ dbhost, $ dbuser, $ dbpw );
Mysql_query ("set names 'utf8 '");
Mysql_query ("set character_set_client = utf8 ");
Mysql_query ("set character_set_results = utf8 ");
If ($ dbname ){
Mysql_select_db ($ dbname, $ this-> dblink );
}
}
Function query ($ SQL ){
$ Result = mysql_query ($ SQL, $ this-> dblink );
Return $ result;
}
Function fetch_array ($ result ){
Return mysql_fetch_array ($ result );
}
Function insert_id (){
$ Id = mysql_insert_id ();
Return $ id;
}
Function getrow ($ SQL ){
$ Result = mysql_query ($ SQL, $ this-> dblink );
Return mysql_fetch_assoc ($ result );
}
Function getdetailrow ($ SQL ){
$ Result = mysql_query ($ SQL, $ this-> dblink );
Return mysql_fetch_array ($ result );
}
// Www. bKjia. c0m
Function close (){
Mysql_close ($ this-> dblink );
}
}
// Call method
$ Db = new database;
$ Db-> connect ($ dbhost, $ dbuser, $ dbpw, $ dbname );
Unset ($ dbhost, $ dbuser, $ dbpw, $ dbname );
?>
Logging and other simple mysql databases...