Example #1
0
 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);
     }
 }