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 $table * @param int $cacheTtl * @param bool $flushCache * @return array */ protected function _getColumnsByTableFromDb($table, $cacheTtl = self::CACHE_NO, $flushCache = false) { Assert($table)->string()->notEmpty(); $callback = function () use($table) { return $this->_connection->getColumns(true, $table); }; $cacheKey = '/column_schema/' . $table; if ($flushCache === true) { $this->clearCache($cacheKey); } return $this->_cacheData($cacheKey, $callback, $cacheTtl); }
/** * @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()); }