一個MYSQL操作類
更新時間:2006年11月16日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<?php
class DB{
var $host_addr = "localhost";
var $host_user = "root";
var $host_psw = "123";
var $db_name = "test";
var $link_id;
var $query_id;
var $numRow;
function DB(){
$this->link_id = @mysql_connect($this->host_addr,$this->host_user,$this->host_psw);
if($this->link_id){
@mysql_select_db($this->db_name,$this->link_id) or $this->halt("數(shù)據(jù)庫連接失??!");
}else{
$this->halt("連接服務(wù)器失??!");
return false;
}
return $this->link_id;
}
function query($sql){
$this->query_id = @mysql_query($sql,$this->link_id);
if($this->query_id){
return $this->query_id;
}else{
$this->halt("SQL Error::");
return false;
}
}
function numRow(){
return $this->numRow = @mysql_num_rows($this->query_id);
}
function close(){
return @mysql_close($this->link_id);
}
function halt($msg){
echo "<font color=\"#FF0000\">".$msg."</font>";
}
}
?>
相關(guān)文章
php進(jìn)程daemon化的正確實現(xiàn)方法
守護(hù)進(jìn)程(Daemon)是運行在后臺的一種特殊進(jìn)程。下面這篇文章主要給大家介紹了關(guān)于php進(jìn)程daemon化的正確實現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-09-09

