封装连接类

<?php
class DBDA
{
public $host="localhost";
public $uid = "root";
public $pwd = "123";
public $dbname = "mydb";

//成员方法
public function Query($sql,$type=1)
{
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
$r = $db->query($sql);

if($type==1)
{
return $r->fetch_all();
}
else
{
return $r;
}
}
}

原文地址:https://www.cnblogs.com/l123789/p/6237503.html