Class WebApp public db public function __construct host dbname user pa

1
2
3
4
5
6
7
8
9
Class WebApp
{
public $db;
public function __construct($host, $dbname, $user, $pass)
{
$this->db=new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$this->db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION );
$this->db->exec('SET CHARACTER SET utf8');
}