使用面向对象封装类实现连接数据库

时间:2022-12-11 08:20:43
<?php




class conn
{
var $host='localhost';
var $user='root';
var $pass='';
var $db='test';
var $point='3306';




function connect(){
$connect=mysqli_connect("localhost","root","","test","3306");
if (mysqli_query($connect,"set names utf8")){
return true;
}
else{
return false;
}
}
function sel($sql){
$connect=mysqli_connect("localhost","root","","test","3306");
$res=mysqli_query($connect,$sql);
return $res;
}
function fetch($a){
return mysqli_fetch_assoc($a);
}




}