Soruya ek: Süslü parantezler neden konulmuş?
public function __construct($username, $password, $host, $dbname, $options=array()){
$this->isConnected = true;
try {
$this->datab = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);
$this->datab->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->datab->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
catch(PDOException $e) {
$this->isConnected = false;
throw new Exception($e->getMessage());
}
Kodun alındığı yer:
http://codereview.stackexchange.com/questions/29362/very-simple-php-pdo-class