{
$this->connect();
}
private function connect()
{
$connect = require_once 'connect.php';
$dsn = 'mysql:host='.$connect['host'].';dbname='.$connect['db_name'].';charset='.$connect['charset'];
$this->$link = new PDO ($dsn, $connect['username'], $connect['password']);
return $this;
}
public function execute($sql)
{
$sth = $this ->link->prepare($sql);
return $sth-execute();
}
public function query($sql)
{
$exe = $this -> execute($sql);
$result = $exe -> fetchAll(PDO::FEATCH_ASSOC);
if($result === false){
return[];
}
return $relult;
}
}
$db = new Database();
$db ->execute("INSERT INTO client SET username`='Mikola',`password = '1234567'");
у конструктора два подчеркивания должно быть
Обсуждают сегодня