php连接数据库的配置

代码如下

db_host.":dbname=".$this->dn_name.":charset=utf8";
$db_user=$this->db_user;
$db_pass=$this->db_pass;
$this->pdo=new PDO($dsn,$db_user,$db_pass);



}
//对于数据库的表增删改查

//删除
public function delete($sql){
return $this->pdo->exec($sql);

}
//修改
public function modify($sql){

return $this->pdo->exec($sql);


}
//查询
public function query($sql){
$pdoStatement=$this->pdo->query($aql,PDO::FETCH_ASSOC);
$data=$pdoStatement->fetchAll();
return $data;
}

public function add($sql){
$this->pdo->exec($sql);
return $this->pdo->LastInsertId();

}

}

?>

 

你可能感兴趣的:(web后端)