本文整理匯總了PHP中fORM::getDatabaseName方法的典型用法代碼示例。如果您正苦於以下問題:PHP fORM::getDatabaseName方法的具體用法?PHP fORM::getDatabaseName怎麽用?PHP fORM::getDatabaseName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fORM
的用法示例。
在下文中一共展示了fORM::getDatabaseName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testClassToDatabaseMapping
public function testClassToDatabaseMapping()
{
$this->assertEquals('default', fORM::getDatabaseName('User'));
$this->assertEquals('default', fORM::getDatabaseName('PhotoGallery'));
fORM::mapClassToDatabase('User', 'second_db');
$this->assertEquals('second_db', fORM::getDatabaseName('User'));
}
示例2: retrieve
/**
* Return the instance of the fSchema class
*
* @param string $class The class the object will be used with
* @return fSchema The schema instance
*/
public static function retrieve($class = 'fActiveRecord')
{
if (substr($class, 0, 5) == 'name:') {
$database_name = substr($class, 5);
} else {
$database_name = fORM::getDatabaseName($class);
}
if (!isset(self::$schema_objects[$database_name])) {
self::$schema_objects[$database_name] = new fSchema(fORMDatabase::retrieve($class));
}
return self::$schema_objects[$database_name];
}
示例3: retrieve
/**
* Return the instance of the fDatabase class
*
* @param string $class The class to retrieve the database for - if not specified, the default database will be returned
* @param string $role If the database will be used for `'write'`, `'read'` or `'either'` operations
* @return fDatabase The database instance
*/
public static function retrieve($class = 'fActiveRecord', $role = 'either')
{
if (substr($class, 0, 5) == 'name:') {
$database_name = substr($class, 5);
} else {
$database_name = fORM::getDatabaseName($class);
}
if (!isset(self::$database_objects[$database_name])) {
throw new fProgrammerException('The database object named "%1$s" has not been attached via %2$s yet', $database_name, __CLASS__ . '::attach()');
}
if ($role == 'write' || $role == 'read') {
// If the user wants a read database but we are in a transaction on the write database, return
// the write database to allow for comparing data changed since the transaction started
if ($role == 'read' && isset(self::$database_objects[$database_name]['write']) && self::$database_objects[$database_name]['write']->isInsideTransaction()) {
$role = 'write';
}
if (!isset(self::$database_objects[$database_name][$role])) {
throw new fProgrammerException('The database object named "%1$s" for the %s$2 role has not been attached via %3$s yet', $database_name, $role, __CLASS__ . '::attach()');
}
return self::$database_objects[$database_name][$role];
}
if (isset(self::$database_objects[$database_name]['write'])) {
return self::$database_objects[$database_name]['write'];
} elseif (isset(self::$database_objects[$database_name]['read'])) {
return self::$database_objects[$database_name]['read'];
}
}