当前位置: 首页>>代码示例>>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;未经允许,请勿转载。