コード例 #1
0
ファイル: DBMySQL.php プロジェクト: timesplinter/tsfw-db
 public function __construct(DBConnect $dbConnect)
 {
     $this->dbConnect = $dbConnect;
     try {
         parent::__construct('mysql:host=' . $dbConnect->getHost() . ';dbname=' . $dbConnect->getDatabase() . ($dbConnect->getCharset() !== null ? ';charset=' . $dbConnect->getCharset() : null), $dbConnect->getUsername(), $dbConnect->getPassword());
         $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         $this->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
         if (($charset = $dbConnect->getCharset()) !== null) {
             $this->query("SET NAMES '" . $charset . "'");
             $this->query("SET CHARSET '" . $charset . "'");
         }
         $this->triggerListeners('onConnect', array($this, $this->dbConnect));
     } catch (\PDOException $e) {
         throw new DBException($e);
     }
 }