本文整理汇总了PHP中RedBeanDatabase::getDatabaseTypeFromDsnString方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanDatabase::getDatabaseTypeFromDsnString方法的具体用法?PHP RedBeanDatabase::getDatabaseTypeFromDsnString怎么用?PHP RedBeanDatabase::getDatabaseTypeFromDsnString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanDatabase
的用法示例。
在下文中一共展示了RedBeanDatabase::getDatabaseTypeFromDsnString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$matches = array();
assert(preg_match("/host=([^;]+);(?:port=([^;]+);)?dbname=([^;]+)/", Yii::app()->db->connectionString, $matches) == 1);
// Not Coding Standard
if ($matches[2] != '') {
$this->databasePort = intval($matches[2]);
} else {
$databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString(Yii::app()->db->connectionString);
$this->databasePort = DatabaseCompatibilityUtil::getDatabaseDefaultPort($databaseType);
}
$this->hostname = $matches[1];
$this->rootUsername = Yii::app()->db->username;
$this->rootPassword = Yii::app()->db->password;
$this->existingDatabaseName = $matches[3];
$this->temporaryDatabaseName = "zurmo_wacky";
if ($this->rootUsername == 'zurmo') {
$this->rootUsername = 'zurmoroot';
$this->rootPassword = 'somepass';
$this->temporaryDatabaseName = 'zurmo_wacky';
}
$this->superUserPassword = 'super';
$this->databaseBackupTestFile = INSTANCE_ROOT . '/protected/runtime/databaseBackupTest.sql';
}
示例2: testGetDatabaseTypeFromDsnString
/**
* @expectedException NotSupportedException
*/
public function testGetDatabaseTypeFromDsnString()
{
$dsn = 'mysql:host=localhost;port=3306;dbname=zurmo';
// Not Coding Standard
$databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn);
$this->assertEquals('mysql', $databaseType);
$dsn = 'oci:host=localhost;dbname=zurmo';
// Not Coding Standard
$databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn);
$this->assertEquals('oci', $databaseType);
// Invalid connection string, so NotSupportedException should be thrown.
$dsn = 'host=localhost;dbname=zurmo';
// Not Coding Standard
$databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn);
}