当前位置: 首页>>代码示例>>PHP>>正文


PHP CDbConnection::init方法代码示例

本文整理汇总了PHP中CDbConnection::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbConnection::init方法的具体用法?PHP CDbConnection::init怎么用?PHP CDbConnection::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDbConnection的用法示例。


在下文中一共展示了CDbConnection::init方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  *
  */
 public function init()
 {
     try {
         parent::init();
     } catch (\CDbException $e) {
         Craft::log($e->getMessage(), LogLevel::Error);
         $missingPdo = false;
         // TODO: Multi-db driver check.
         if (!extension_loaded('pdo')) {
             $missingPdo = true;
             $messages[] = Craft::t('Craft requires the PDO extension to operate.');
         }
         if (!extension_loaded('pdo_mysql')) {
             $missingPdo = true;
             $messages[] = Craft::t('Craft requires the PDO_MYSQL driver to operate.');
         }
         if (!$missingPdo) {
             Craft::log($e->getMessage(), LogLevel::Error);
             $messages[] = Craft::t('There is a problem connecting to the database with the credentials supplied in your db config file.');
         }
     } catch (\Exception $e) {
         Craft::log($e->getMessage(), LogLevel::Error);
         $messages[] = Craft::t('There is a problem connecting to the database with the credentials supplied in your db config file.');
     }
     if (!empty($messages)) {
         throw new DbConnectException(Craft::t('Database configuration errors: {errors}', array('errors' => implode(PHP_EOL, $messages))));
     }
     $this->_isDbConnectionValid = true;
     // Now that we've validated the config and connection, set extra db logging if devMode is enabled.
     if (craft()->config->get('devMode')) {
         $this->enableProfiling = true;
         $this->enableParamLogging = true;
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:37,代码来源:DbConnection.php

示例2: testInitialized

 public function testInitialized()
 {
     $db = new CDbConnection();
     $db->autoConnect = false;
     $this->assertFalse($db->isInitialized);
     $db->init();
     $this->assertTrue($db->isInitialized);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:8,代码来源:CDbConnectionTest.php

示例3: createDbConnection

 public function createDbConnection($db_must_exists = true)
 {
     $conn_string = 'mysql:host=' . $this->db_host . ';' . ($db_must_exists ? 'dbname=' . $this->db_name : '');
     $con = new CDbConnection($conn_string, $this->db_login, $this->db_pass);
     $con->initSQLs = array("SET NAMES 'utf8' COLLATE 'utf8_general_ci';");
     $con->init();
     return $con;
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:8,代码来源:Step1.php

示例4: testCreateDb

 public function testCreateDb()
 {
     $step1 = new Step1();
     $step1->setAttributes($this->data, false);
     $this->assertTrue($step1->createDb());
     $conn_string = 'mysql:host=' . $step1->db_host . ';dbname=' . $step1->db_name;
     $con = new CDbConnection($conn_string, $step1->db_login, $step1->db_pass);
     try {
         $con->init();
     } catch (Exception $e) {
         $this->assert('Db was not created');
     }
     $con->createCommand('DROP DATABASE IF EXISTS ' . $con->quoteTableName($this->data['db_name']))->execute();
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:14,代码来源:Step1Test.php

示例5: setupConnection

 /**
  * 
  * @param string $attribute
  * @param mixed[] $params
  */
 public function setupConnection($attribute, $params)
 {
     if ($this->dbhost === 'localhost') {
         $this->clearErrors('dbhost');
     }
     if (!$this->hasErrors()) {
         $str = $this->dbtype . ':host=' . $this->dbhost . ':' . $this->dbport . ';dbname=' . $this->dbname;
         if ($this->dbtype === 'mysql' || $this->dbtype === 'mysqli') {
             $str .= ';charset=' . $this->dbenco;
         }
         $connection = new CDbConnection($str, $this->dbuser, $this->dbpass);
         $connection->charset = $this->dbenco;
         try {
             $connection->init();
             $this->connection = $connection;
         } catch (CException $e) {
             $this->addError($attribute, Yii::t('dbms.form', 'Impossible to connect to "{cstr}" with given user ({message}).', array('{cstr}' => $connection->connectionString, '{message}' => $e->getMessage())));
         }
     }
     if ($this->connection === null) {
         $this->dbpass = null;
     }
 }
开发者ID:anastaszor,项目名称:yii1-dbms,代码行数:28,代码来源:InstallationForm.php

示例6: init

 public function init()
 {
     $this->setAttribute(PDO::ATTR_TIMEOUT, $this->dbaTimeout);
     parent::init();
 }
开发者ID:Renbaozhan,项目名称:ecar,代码行数:5,代码来源:DBAConnection.php

示例7: init

 /**
  * Initializes the component.
  * This method is required by {@link IApplicationComponent} and is invoked by application
  * when the CDbConnection is used as an application component.
  * If you override this method, make sure to call the parent implementation
  * so that the component can be marked as initialized.
  */
 public function init()
 {
     parent::init();
     if ($this->autoConnect) {
         $this->setActive(true);
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:14,代码来源:DbConnection.php

示例8: init

 public function init()
 {
     parent::init();
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:4,代码来源:DbConnection.php


注:本文中的CDbConnection::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。