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


PHP Connection::className方法代码示例

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


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

示例1: init

 public function init()
 {
     $this->db = Instance::ensure($this->db, Connection::className());
     parent::init();
     // Note the default configuration data value will not store to database.
     $this->data = array_merge($this->loadData(), $this->data);
 }
开发者ID:lichunqiang,项目名称:yii2-config,代码行数:7,代码来源:DbConfig.php

示例2: init

 public function init()
 {
     parent::init();
     $this->i2db = Instance::ensure($this->i2db, Connection::className());
     $this->infodb = Instance::ensure($this->infodb, Connection::className());
     $this->db46 = Instance::ensure($this->db46, Connection::className());
 }
开发者ID:didwjdgks,项目名称:yii2-pur-gman,代码行数:7,代码来源:Module.php

示例3: __construct

 public function __construct($db = 'db')
 {
     $this->db = Instance::ensure($db, Connection::className());
     $this->generator = new Generator();
     $this->dbHelper = new Migration(['db' => $this->db]);
     $this->generatorConfigurator = new GeneratorConfigurator();
 }
开发者ID:tebazil,项目名称:yii2-db-seeder,代码行数:7,代码来源:Seeder.php

示例4: init

 /**
  * Initializes the migration.
  * This method will set [[db]] to be the 'db' application component, if it is `null`.
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     $this->db->getSchema()->refresh();
     $this->db->enableSlaves = false;
 }
开发者ID:kilyanov,项目名称:yii2,代码行数:11,代码来源:Migration.php

示例5: init

 public function init()
 {
     parent::init();
     $db = Instance::ensure($this->db, Connection::className());
     $query = new Query();
     $this->ticket = $query->select(['*'])->from($this->table)->createCommand($db)->queryAll();
 }
开发者ID:axiles89,项目名称:yii2-viewgrid,代码行数:7,代码来源:Axiles89Grid.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->mockApplication();
     Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => 'sqlite::memory:']);
     Yii::$app->db->createCommand()->createTable('session', ['id' => 'string', 'expire' => 'integer', 'data' => 'text', 'user_id' => 'integer'])->execute();
 }
开发者ID:advance100,项目名称:yunjianyi,代码行数:7,代码来源:DbSessionTest.php

示例7: init

 /**
  * Initializes the DbMessageSource component.
  * This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
  * Configured [[cache]] component would also be initialized.
  * @throws InvalidConfigException if [[db]] is invalid or [[cache]] is invalid.
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     if ($this->enableCaching) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:fonclub,项目名称:i18n,代码行数:14,代码来源:DbMessageSource.php

示例8: mockApplication

 /**
  * Populates Yii::$app with a new application
  * The application will be destroyed on tearDown() automatically.
  * @param array $config The application configuration, if needed
  * @param string $appClass name of the application class to create
  */
 protected function mockApplication($config = [], $appClass = '\\yii\\console\\Application')
 {
     new $appClass(ArrayHelper::merge(['id' => 'testapp', 'basePath' => __DIR__, 'vendorPath' => '../../vendor', 'controllerMap' => ['deferred' => ['class' => DeferredController::className()]], 'components' => ['mutex' => ['class' => 'yii\\mutex\\MysqlMutex', 'autoRelease' => false], 'db' => ['class' => Connection::className(), 'dsn' => 'mysql:host=localhost;dbname=yii2_deferred_tasks', 'username' => 'root', 'password' => ''], 'cache' => ['class' => 'yii\\caching\\FileCache']]], $config));
     Yii::$app->cache->flush();
     Yii::$app->getDb()->open();
     Yii::$app->runAction('migrate/down', [99999, 'interactive' => 0, 'migrationPath' => __DIR__ . '/../src/migrations/']);
     Yii::$app->runAction('migrate/up', ['interactive' => 0, 'migrationPath' => __DIR__ . '/../src/migrations/']);
 }
开发者ID:duvanskiy,项目名称:yii2-deferred-tasks,代码行数:14,代码来源:DeferredControllerTest.php

示例9: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->db = Instance::ensure($this->db, Connection::className());
         return true;
     }
     return false;
 }
开发者ID:jamband,项目名称:yii2-schemadump,代码行数:11,代码来源:SchemaDumpController.php

示例10: exec

 public function exec($aliasPath)
 {
     $path = str_replace('/', DIRECTORY_SEPARATOR, \Yii::getAlias($aliasPath));
     $this->migrationPath = dirname($path);
     $this->db = Instance::ensure($this->db, Connection::className());
     $this->getNewMigrations();
     return $this->migrateUp(basename($path));
 }
开发者ID:carono,项目名称:yii2-installer,代码行数:8,代码来源:MigrateController.php

示例11: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     if (is_string($this->cache)) {
         $this->cache = Yii::$app->get($this->cache, false);
     }
 }
开发者ID:marley-php,项目名称:linuxforum,代码行数:11,代码来源:Config.php

示例12: down

 public function down()
 {
     $configs = array_merge($this->configs, ArrayHelper::getValue(Yii::$app->params, 'migration.rbac', []));
     $this->db = Instance::ensure($configs['db'], Connection::className());
     $this->dropTable($configs['assignmentTable']);
     $this->dropTable($configs['itemChildTable']);
     $this->dropTable($configs['itemTable']);
     $this->dropTable($configs['ruleTable']);
 }
开发者ID:sangkil,项目名称:biz3-distro,代码行数:9,代码来源:m140506_102106_rbac_init.php

示例13: actionDatabase

 /**
  * Database action is responsible for all database related stuff.
  * Checking given database settings, writing them into a config file.
  *
  * (Step 3)
  */
 public function actionDatabase()
 {
     $success = FALSE;
     $errorMsg = '';
     $config = Configuration::get();
     $param = Configuration::getParam();
     $form = new DatabaseForm();
     if ($form->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($form);
         }
         if ($form->validate()) {
             $dsn = "mysql:host=" . $form->hostname . ";dbname=" . $form->database;
             // Create Test DB Connection
             Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => $dsn, 'username' => $form->username, 'password' => $form->password, 'charset' => 'utf8']);
             try {
                 Yii::$app->db->open();
                 // Check DB Connection
                 if (InstallerModule::checkDbConnection()) {
                     // Write Config
                     $config['components']['db']['class'] = Connection::className();
                     $config['components']['db']['dsn'] = $dsn;
                     $config['components']['db']['username'] = $form->username;
                     $config['components']['db']['password'] = $form->password;
                     $config['components']['db']['charset'] = 'utf8';
                     // Write config for future use
                     $param['installer']['db']['installer_hostname'] = $form->hostname;
                     $param['installer']['db']['installer_database'] = $form->database;
                     $param['installer']['db']['installer_username'] = $form->username;
                     Configuration::set($config);
                     Configuration::setParam($param);
                     $success = TRUE;
                     return $this->redirect(Yii::$app->urlManager->createUrl('//installer/setup/mailer'));
                 } else {
                     $errorMsg = 'Incorrect configuration';
                 }
             } catch (Exception $e) {
                 $errorMsg = $e->getMessage();
             }
         }
     } else {
         if (isset($param['installer']['db']['installer_hostname'])) {
             $form->hostname = $param['installer']['db']['installer_hostname'];
         }
         if (isset($param['installer']['db']['installer_database'])) {
             $form->database = $param['installer']['db']['installer_database'];
         }
         if (isset($param['installer']['db']['installer_username'])) {
             $form->username = $param['installer']['db']['installer_username'];
         }
     }
     return $this->render('database', ['model' => $form, 'success' => $success, 'errorMsg' => $errorMsg]);
 }
开发者ID:abhi1693,项目名称:yii2-installer,代码行数:60,代码来源:SetupController.php

示例14: init

 /**
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (empty($this->db)) {
         throw new InvalidConfigException('UserConfig::db must be set.');
     }
     $this->db = Instance::ensure($this->db, Connection::className());
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:cdcchen,项目名称:yii-plus,代码行数:14,代码来源:UserConfig.php

示例15: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the [[migrationPath]].
  *
  * @param \yii\base\Action $action the action to be executed.
  *
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if ($action->id !== 'create') {
             $this->db = Instance::ensure($this->db, Connection::className());
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:c006,项目名称:yii2-console,代码行数:19,代码来源:AutoController.php


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