哪位前辈有空帮我逐行解释段php+mysql类

来源:百度知道 编辑:UC知道 时间:2024/05/27 11:56:12
<?php

class mysql{

private $host;
private $name;
private $pass;
private $table;
private $ut;

function __construct($host,$name,$pass,$table,$ut){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->table=$table;
$this->ut=$ut;
$this->connect();

}

function connect(){
$link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());
mysql_select_db($this->table,$link) or die("没该数据库:".$this->table);
mysql_query("SET NAMES '$this->ut'");
}

function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('Say:', $sql);
return $query;
}

function show($message = '', $sql = '') {
i

<?php

class mysql{

private $host; //数据库连接服务器
private $name; //数据库连接用户名
private $pass; //数据库连接密码
private $table; //数据库连接库名称 不知为什么用table
private $ut;//数据库连接字符集

function __construct($host,$name,$pass,$table,$ut){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->table=$table;
$this->ut=$ut;
$this->connect();

}//类构建

function connect(){
$link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());////数据库连接
mysql_select_db($this->table,$link) or die("没该数据库:".$this->table);//选择数据库
mysql_query("SET NAMES '$this->ut'");//选择字符集
}

function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('Say:', $sql);
return $