當前位置: 首頁>>代碼示例>>PHP>>正文


PHP fORM::getDatabaseName方法代碼示例

本文整理匯總了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'));
 }
開發者ID:nurulimamnotes,項目名稱:flourish-old,代碼行數:7,代碼來源:fORMTest.php

示例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];
 }
開發者ID:philip,項目名稱:flourish,代碼行數:18,代碼來源:fORMSchema.php

示例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'];
     }
 }
開發者ID:hibble,項目名稱:printmaster,代碼行數:34,代碼來源:fORMDatabase.php


注:本文中的fORM::getDatabaseName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。