Granada\ORM::configure PHP Method

configure() public static method

Pass configuration settings to the class in the form of key/value pairs. As a shortcut, if the second argument is omitted and the key is a string, the setting is assumed to be the DSN string used by PDO to connect to the database (often, this will be the only configuration required to use Idiorm). If you have more than one setting you wish to configure, another shortcut is to pass an array of settings (and omit the second argument).
public static configure ( string $key, mixed $value = null, string $connection_name = self::DEFAULT_CONNECTION )
$key string
$value mixed
$connection_name string Which connection to use
    public static function configure($key, $value = null, $connection_name = self::DEFAULT_CONNECTION)
    {
        self::_setup_db_config($connection_name);
        //ensures at least default config is set
        if (is_array($key)) {
            // Shortcut: If only one array argument is passed,
            // assume it's an array of configuration settings
            foreach ($key as $conf_key => $conf_value) {
                self::configure($conf_key, $conf_value, $connection_name);
            }
        } else {
            if (is_null($value)) {
                // Shortcut: If only one string argument is passed,
                // assume it's a connection string
                $value = $key;
                $key = 'connection_string';
            }
            self::$_config[$connection_name][$key] = $value;
        }
    }

Usage Example

 public function setUp()
 {
     // Enable logging
     ORM::configure('logging', true);
     // Set up the dummy database connection
     $db = new PDO('sqlite::memory:');
     ORM::set_db($db);
 }
All Usage Examples Of Granada\ORM::configure
ORM