/** * * @param \Fobia\Base\Application $app * @param array $map * @internal */ public function __construct(Application $app, $map = array()) { $this->app = $app; $this->map = array_merge($this->map, $map); $this->status = self::STATUS_AUTH_NONE; if (class_exists('\\Fobia\\Debug\\Log')) { $this->logger = \Fobia\Debug\Log::getLogger(); } else { $this->logger = new \Psr\Log\NullLogger(); } }
/** * Создает объект из параметров $dbParams. * * Supported database parameters are: * - dbname|database: Database name * - user|username: Database user name * - pass|password: Database user password * - host|hostspec: Name of the host database is running on * - port: TCP port * - charset: Client character set * - socket: UNIX socket path * * @param array $dbParams Database connection parameters (key=>value pairs). */ public function __construct(array $dbParams) { parent::__construct($dbParams); $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Fobia\\DataBase\\DbStatement', array($this))); if (@$dbParams['params']['logger'] instanceof \Psr\Log\LoggerInterface) { $this->logger = $dbParams['params']['logger']; } else { $this->logger = class_exists('\\Fobia\\Debug\\Log') ? \Fobia\Debug\Log::getLogger() : new \Psr\Log\NullLogger(); } if (isset($dbParams['params']['log_error'])) { $this->log_error = $dbParams['params']['log_error']; } // if (@$dbParams['charset']) { // parent::query("SET NAMES '{$dbParams['charset']}'"); // } $this->getLogger()->info('[SQL]:: Connect database', array($dbParams['database'])); if (@$dbParams['params']['debug']) { parent::query('SET profiling = 1'); $this->profiles = true; $this->logger->debug('==> Set profiling'); } }