public function __construct($dsn, $username = null, $passwd = null, $options = [], AbstractLogger $logger = null, CacheInterface $cache = null) { parent::__construct($dsn, $username, $passwd, $options); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $this->setConfig($options, $dsn); $this->setLogger($logger ? $logger : new NullLogger()); $this->setCache($cache ? $cache : new NullCache()); }
/** * @param string $dsn * @param string $username * @param string $passwd * @param array $options * @param AbstractLogger $logger * @param CacheInterface $cache */ public function __construct($dsn, $username = null, $passwd = null, $options = [], AbstractLogger $logger = null, CacheInterface $cache = null) { parent::__construct($dsn, $username, $passwd, $options); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); if (array_key_exists('timeout', $options) && $options['timeout']) { $this->setAttribute(PDO::ATTR_TIMEOUT, (int) $options['timeout']); } $this->exec("SET NAMES utf8 COLLATE utf8_unicode_ci"); $this->setConfig($options, $dsn); $this->setLogger($logger ? $logger : new NullLogger()); $this->setCache($cache ? $cache : new NullCache()); }