php mysql数据库连接类程序代码
来源:未知
时间:2014-11-27 23:50 作者:xxadmin
阅读:次
[导读] lasscls_mysql{ var $querynum =0; var $link ; var $histories ; var $dbhost ; var $dbuser ; var $dbpw ; var $dbcharset ; var $pconnect ; var $tablepre ; var $time ; var $goneaway =5; function connect( $dbhost , $dbuser , $dbpw , $dbname = , $...
-
lass cls_mysql{
-
var $querynum = 0;
-
var $link;
-
var $histories;
-
var $dbhost;
-
var $dbuser;
-
var $dbpw;
-
var $dbcharset;
-
var $pconnect;
-
var $tablepre;
-
var $time;
-
var $goneaway = 5;
-
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre='', $time = 0) {
-
$this->dbhost = $dbhost;
-
$this->dbuser = $dbuser;
-
$this->dbpw = $dbpw;
-
$this->dbname = $dbname;
-
$this->dbcharset = $dbcharset;
-
$this->pconnect = $pconnect;
-
$this->tablepre = $tablepre;
-
$this->time = $time;
-
if($pconnect) {
-
if(!$this->link = mysql_pconnect($dbhost, $dbuser, $dbpw)) {
-
$this->halt('can not connect to mysql server');
-
}
-
} else {
-
if(!$this->link = mysql_connect($dbhost, $dbuser, $dbpw)) {
-
$this->halt('can not connect to mysql server');
-
}
-
}
-
if($this->version() > '4.1') {
-
if($dbcharset) {
-
mysql_query("set character_set_connection=".$dbcharset.", character_set_results=".$dbcharset.", character_set_client=binary", $this->link);
-
}
-
if($this->version() > '5.0.1') {
-
mysql_query("set sql_mode=''", $this->link);
-
}
-
}
-
if($dbname) {
-
mysql_select_db($dbname, $this->link);
-
}
-
}
-
function fetch_array($query, $result_type = mysql_assoc) {
-
return mysql_fetch_array($query, $result_type);
-
}
-
function result_first($sql) {
-
$query = $this->query($sql);
-
return $this->result($query, 0);
-
}
-
function fetch_first($sql) {
-
$query =
|