Example #1
0
 /**
  * Selects a different database for the Facade to work with.
  * If you use the R::setup() you don't need this method. This method is meant
  * for multiple database setups. This method selects the database identified by the
  * database ID ($key). Use addDatabase() to add a new database, which in turn
  * can be selected using selectDatabase(). If you use R::setup(), the resulting
  * database will be stored under key 'default', to switch (back) to this database
  * use R::selectDatabase( 'default' ). This method returns TRUE if the database has been
  * switched and FALSE otherwise (for instance if you already using the specified database).
  *
  * @param  string $key Key of the database to select
  *
  * @return boolean
  */
 public static function selectDatabase($key)
 {
     if (self::$currentDB === $key) {
         return FALSE;
     }
     self::configureFacadeWithToolbox(self::$toolboxes[$key]);
     self::$currentDB = $key;
     return TRUE;
 }
Example #2
0
 /**
  * Selects a different database for the Facade to work with.
  * If you use the R::setup() you don't need this method. This method is meant
  * for multiple database setups. This method selects the database identified by the
  * database ID ($key). Use addDatabase() to add a new database, which in turn
  * can be selected using selectDatabase(). If you use R::setup(), the resulting
  * database will be stored under key 'default', to switch (back) to this database
  * use R::selectDatabase( 'default' ). This method returns TRUE if the database has been
  * switched and FALSE otherwise (for instance if you already using the specified database).
  *
  * @param  string $key Key of the database to select
  *
  * @return boolean
  */
 public static function selectDatabase($key)
 {
     if (self::$currentDB === $key) {
         return FALSE;
     }
     if (!isset(self::$toolboxes[$key])) {
         throw new RedException('Database not found in registry. Add database using R::addDatabase().');
     }
     self::configureFacadeWithToolbox(self::$toolboxes[$key]);
     self::$currentDB = $key;
     return TRUE;
 }