php简单的mysql类_超简单php mysql数据库查询类
本文章為你免費提供一款漂亮的超簡單php mysql數據庫查詢類哦
*/
class Config{
private $host;??????? //主機名稱:一般是localhost
private $root;??????? //數據庫教程帳號:一般是root
private $password;??? //數據庫密碼:一般為空
private $datebase;??? //數據庫名稱:一般自己定義
private $ut;????????? //編碼問題如:utf-8gbk
//初始化這個類的變量
function __construct($host,$root,$password,$datebase,$ut){
$this->host=$host;????????? //初始化主機名稱
$this->root=$root;????????? //初始化數據庫帳號
$this->password=$password;? //初始化數據庫密碼
$this->datebase=$datebase;? //初始化數據庫名稱
$this->conn();????????????? //初始化連接數據庫的方法
$this->ut=$ut;????????????? //初始化編碼
}
//常用連接數據庫的方法
function conn(){
$conn = mysql教程_connect($this->host,$this->root,$this->password) or die ($this->error());
mysql_select_db($this->datebase,$conn) or die ("沒有這個數據庫:".$this->datebase);
mysql_query("SET NAMES '$this->ut'");
}
//常用傳送sql到數據庫的方法
function query($v){
return mysql_query($v);
}
//常用函數查看數據
function fetch_row($query){
return mysql_fetch_row($query);
}
//常用錯誤的方法
function error(){
return mysql_error();
}
//常用關閉數據庫的方法
function close(){
return mysql_close();
}
}
?>
總結
以上是生活随笔為你收集整理的php简单的mysql类_超简单php mysql数据库查询类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为怎么看?全球用户认为4G足够 运营商
- 下一篇: mysql 核对_核对数据库表记录的sh