<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<?php
class DBDA{
public $host = "localhost";
public $uid = "root";
public $pwd = "";
public $dbname = "lianxi";
/*
query方法:执行用户给的SQL语句,并返回相应的结果
$sql:用户需要执行的SQL语句
$type:用户需要执行的SQL语句的类型
return:如果是增删改返回true或false,如果是查询返回二维数组
*/
public function query($sql,$type=0){
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
if(mysqli_connect_error()){
return "连接失败!";
}
$result = $db->query($sql);
if($type){
return $result;
}else{
return $result->fetch_all();
}
}
public function strqurey($sql,$type){
$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
if(mysqli_connect_error()){
return "连接失败!";
}
$result = $db->query($sql);
if($type){
return $result;
}else{
return $result->fetch_all();
$str="";
foreach($arr as $v){
$str=$str.implode("^", $v)."|";
}
$str=substr($str,0,strlen($str)-1);
return $str;
}
}
}
?>
</body>
</html>