复制代码代码如下:
class DB{
var $host_addr = "localhost";
var $host_user = 「ルート」;
var $host_psw = "123";
var $db_name = 「テスト」;
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("数据库连接失败!");
}else{
$this->halt("连接服务器失败!");
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::");
falseを返します。
}
}
function numRow(){
return $this->numRow = @mysql_num_rows($this->query_id);
}
function close(){
return @mysql_close($this->link_id);
}
function halt($msg){
echo "".$msg."";
}
}
?>
http://www.bkjia.com/PHPjc/316920.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316920.html技術記事代制コード例: ?php classDB{ var$host_addr="localhost"; var$host_user="ルート"; var$host_psw="123"; var$db_name="テスト"; var$link_id; var$query_id; var$numRow; functionDB(...