public function init() { $this->version = 10; $this->type = 'daemon'; parent::init(); }
/** * Creates a {@link DbConnection} specifically initialized for Craft's craft()->db instance. * * @throws DbConnectException * @return DbConnection */ public function createDbConnection() { try { $dbConnection = new DbConnection(); $dbConnection->connectionString = $this->_processConnectionString(); $dbConnection->emulatePrepare = true; $dbConnection->username = craft()->config->get('user', ConfigFile::Db); $dbConnection->password = craft()->config->get('password', ConfigFile::Db); $dbConnection->charset = craft()->config->get('charset', ConfigFile::Db); $dbConnection->tablePrefix = $dbConnection->getNormalizedTablePrefix(); $dbConnection->driverMap = array('mysql' => 'Craft\\MysqlSchema'); $dbConnection->init(); } catch (\CDbException $e) { Craft::log($e->getMessage(), LogLevel::Error); // TODO: Multi-db driver check. if (!extension_loaded('pdo')) { throw new DbConnectException(Craft::t('Craft requires the PDO extension to operate.')); } else { if (!extension_loaded('pdo_mysql')) { throw new DbConnectException(Craft::t('Craft requires the PDO_MYSQL driver to operate.')); } else { Craft::log($e->getMessage(), LogLevel::Error); throw new DbConnectException(Craft::t('Craft can’t connect to the database with the credentials in craft/config/db.php.')); } } } catch (\Exception $e) { Craft::log($e->getMessage(), LogLevel::Error); throw new DbConnectException(Craft::t('Craft can’t connect to the database with the credentials in craft/config/db.php.')); } $this->setIsDbConnectionValid(true); // Now that we've validated the config and connection, set extra db logging if devMode is enabled. if (craft()->config->get('devMode')) { $dbConnection->enableProfiling = true; $dbConnection->enableParamLogging = true; } return $dbConnection; }
public function init() { $this->version = 10; $this->type = 'panel'; parent::init(); }