<?php
class AcessoBD{
private $conn;
private $host;
private $dbname;
private $username;
private $password;
public function __construct($dbname){
$this ->host="localhost";
$this ->dbname=$dbname;
$this ->username="root";
$this ->password="";
$this ->setConn();
}
private function setConn(){
try {
$this ->conn = new PDO("mysql:host=".$this->host.";dbname=".$this->dbname, $this->username, $this->password);
$this ->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
public function select($sql,$parametros){
$stmt = $this ->conn->prepare($sql);
$stmt->execute($parametros);
return $stmt ->fetchAll();
}
}
?>