PHP connection MySQL Database class This is a simple and practical PHP connection MySQL database class, only to do the data query, return the array set, get a new ID to get the record line, such as simple MySQL database connection code.
PHP Tutorial connecting MySQL Tutorial Database Tutorial class
This is a simple and practical PHP connection MySQL database class, only do the data query, return the array set, get the new ID get the record line 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);
}
}
Calling methods
$db = new Database;
$db->connect ($dbhost, $dbuser, $DBPW, $dbname);
Unset ($dbhost, $dbuser, $DBPW, $dbname);
?>
http://www.bkjia.com/PHPjc/630805.html www.bkjia.com true http://www.bkjia.com/PHPjc/630805.html techarticle PHP Connection MySQL database class This is a simple and practical PHP connection MySQL database class, only do the data query, return the array set, get the new ID to get the record row, such as simple MySQL database ...