class Conn_DB{
var $severname = "用户名"; //
var $dbname = "数据库名"; //
var $username ="帐号"; //
var $password ="密码"; //
var $link_id; //
var $num_rows; //
var $query_id; //
var $affected_rows; //
var $insertid; //
function Conn_DB(){#$servername,$dbname,$username,$password
$this -> link_id = @mysql_connect($severname,$username,$password) or die ($this-> link_id = "Link Server Error!");
$this -> link_id = @mysql_select_db($dbname) or die ($this-> link_id = "Link DataBase Error!");
mysql_query("set names 'gbk'");
return $this -> link_id;
}
function Quit($link_id){ //关闭连接
mysql_close($this->link_id);
}
function free_result($query_id){ //释放资源
@mysql_free_result($query_id);
}
function Query($sql_str){//返回单条数据
$this->query_id = @mysql_query($sql_str);
$this->num_rows = @mysql_num_rows($this->query_id);
$RS=@mysql_fetch_array($this->query_id,MYSQL_ASSOC);
if ($this->num_rows == 0) {
$RS = FALSE;
}
$this->free_result($this->query_id);
return $RS;
}
function Query_array($sql_str){//返回多条数据
$this->query_id=@mysql_query($sql_str);
$this->num_rows=@mysql_num_rows($this->query_id) ;
if ($this->num_rows == 0) {
$RSarray = FALSE;
$this->free_result($this->query_id);
return $RSarray;
}else{
for($i=0;$i<$this->num_rows;$i++){
$RSarray[$i]=mysql_fetch_array($this->query_id,MYSQL_ASSOC);
}
$this->free_result($this->query_id);
return $RSarray;
}
}
function Query_noreturn($sql_str){//没有任何返回值
$this->query_id = mysql_query($sql_str);
$this->affected_rows = @mysql_affected_rows();
if ($this->query_id){
$RS = TRUE;
return $RS;
}else{
$RS = FALSE;
return $RS;
}
}
}
?>
var $severname = "用户名"; //
var $dbname = "数据库名"; //
var $username ="帐号"; //
var $password ="密码"; //
var $link_id; //
var $num_rows; //
var $query_id; //
var $affected_rows; //
var $insertid; //
function Conn_DB(){#$servername,$dbname,$username,$password
$this -> link_id = @mysql_connect($severname,$username,$password) or die ($this-> link_id = "Link Server Error!");
$this -> link_id = @mysql_select_db($dbname) or die ($this-> link_id = "Link DataBase Error!");
mysql_query("set names 'gbk'");
return $this -> link_id;
}
function Quit($link_id){ //关闭连接
mysql_close($this->link_id);
}
function free_result($query_id){ //释放资源
@mysql_free_result($query_id);
}
function Query($sql_str){//返回单条数据
$this->query_id = @mysql_query($sql_str);
$this->num_rows = @mysql_num_rows($this->query_id);
$RS=@mysql_fetch_array($this->query_id,MYSQL_ASSOC);
if ($this->num_rows == 0) {
$RS = FALSE;
}
$this->free_result($this->query_id);
return $RS;
}
function Query_array($sql_str){//返回多条数据
$this->query_id=@mysql_query($sql_str);
$this->num_rows=@mysql_num_rows($this->query_id) ;
if ($this->num_rows == 0) {
$RSarray = FALSE;
$this->free_result($this->query_id);
return $RSarray;
}else{
for($i=0;$i<$this->num_rows;$i++){
$RSarray[$i]=mysql_fetch_array($this->query_id,MYSQL_ASSOC);
}
$this->free_result($this->query_id);
return $RSarray;
}
}
function Query_noreturn($sql_str){//没有任何返回值
$this->query_id = mysql_query($sql_str);
$this->affected_rows = @mysql_affected_rows();
if ($this->query_id){
$RS = TRUE;
return $RS;
}else{
$RS = FALSE;
return $RS;
}
}
}
?>