本文整理汇总了PHP中Trigger::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Trigger::db方法的具体用法?PHP Trigger::db怎么用?PHP Trigger::db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trigger
的用法示例。
在下文中一共展示了Trigger::db方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connectDb
/**
* Connects to the specified schema and assigns it to all models which need it.
*
* @param $schema schema
* @return CDbConnection
*/
protected function connectDb($schema)
{
// Assign request
$this->request = Yii::app()->getRequest();
// Check parameter
if (is_null($schema)) {
$this->db = null;
return null;
}
// Connect to database
$connectionString = 'mysql:host=' . Yii::app()->user->host . ';port=' . Yii::app()->user->port . ';dbname=' . $schema . '; charset=utf8';
$this->db = new CDbConnection($connectionString, utf8_decode(Yii::app()->user->name), utf8_decode(Yii::app()->user->password));
$this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES \'utf8\'');
$this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET CHARACTER SET \'utf8\'');
$this->db->charset = 'utf8';
$this->db->emulatePrepare = true;
$this->db->active = true;
// Schema name is set in connection string
// $this->db->createCommand('USE ' . $this->db->quoteTableName($schema))->execute();
// Assign to all models which need it
ActiveRecord::$db = Routine::$db = Row::$db = Trigger::$db = View::$db = $this->db;
// Return connection
return $this->db;
}
示例2: setUp
/**
* Setup test databases.
*/
protected function setUp()
{
$this->executeSqlFile('models/ForeignKeyTest.sql');
Column::$db = ForeignKey::$db = Index::$db = Routine::$db = Row::$db = Schema::$db = Table::$db = Trigger::$db = View::$db = $this->createDbConnection('tabletest');
}
示例3: setUp
/**
* Setup test databases.
*/
protected function setUp()
{
$this->executeSqlFile('models/TriggerTest.sql');
Trigger::$db = $this->createDbConnection('triggertest');
}