Exemplo n.º 1
0
 /**
  * Enables caching on the fDatabase, fSQLTranslation and fSchema objects used for the ORM
  *
  * This method will cache database schema information to the three objects
  * that use it during normal ORM operation: fDatabase, fSQLTranslation and
  * fSchema. To allow for schema changes without having to manually clear
  * the cache, all cached information will be cleared if any
  * fUnexpectedException objects are thrown.
  *
  * This method should be called right after fORMDatabase::attach().
  *
  * @param  fCache $cache          The object to cache schema information to
  * @param  string $database_name  The database to enable caching for
  * @param  string $key_token      This is a token that is used in cache keys to prevent conflicts for server-wide caches - when non-NULL the document root is used
  * @return void
  */
 public static function enableSchemaCaching($cache, $database_name = 'default', $key_token = NULL)
 {
     if ($key_token === NULL) {
         $key_token = $_SERVER['DOCUMENT_ROOT'];
     }
     $token = 'fORM::' . $database_name . '::' . $key_token . '::';
     $db = fORMDatabase::retrieve('name:' . $database_name);
     $db->enableCaching($cache, $token);
     fException::registerCallback($db->clearCache, 'fUnexpectedException');
     $sql_translation = $db->getSQLTranslation();
     $sql_translation->enableCaching($cache, $token);
     $schema = fORMSchema::retrieve('name:' . $database_name);
     $schema->enableCaching($cache, $token);
     fException::registerCallback($schema->clearCache, 'fUnexpectedException');
 }
Exemplo n.º 2
0
 /**
  * Enables caching on the fDatabase, fSQLTranslation and fSchema objects used for the ORM
  * 
  * This method will cache database schema information to the three objects
  * that use it during normal ORM operation: fDatabase, fSQLTranslation and
  * fSchema. To allow for schema changes without having to manually clear
  * the cache, all cached information will be cleared if any
  * fUnexpectedException objects are thrown.
  * 
  * This method should be called right after fORMDatabase::attach().
  *          
  * @param  fCache $cache  The object to cache schema information to
  * @return void
  */
 public static function enableSchemaCaching($cache)
 {
     $db = fORMDatabase::retrieve();
     $db->enableCaching($cache);
     fException::registerCallback($db->clearCache, 'fUnexpectedException');
     $sql_translation = $db->getSQLTranslation();
     $sql_translation->enableCaching($cache);
     fException::registerCallback($sql_translation->clearCache, 'fUnexpectedException');
     $schema = fORMSchema::retrieve();
     $schema->enableCaching($cache);
     fException::registerCallback($schema->clearCache, 'fUnexpectedException');
 }