Granada\ORM::set_db PHP Method

set_db() public static method

This is public in case the ORM should use a ready-instantiated PDO object as its database connection. Accepts an optional string key to identify the connection if multiple connections are used.
public static set_db ( PDO $db, string $connection_name = self::DEFAULT_CONNECTION )
$db PDO
$connection_name string Which connection to use
    public static function set_db($db, $connection_name = self::DEFAULT_CONNECTION)
    {
        self::_setup_db_config($connection_name);
        self::$_db[$connection_name] = $db;
        self::_setup_identifier_quote_character($connection_name);
        self::_setup_limit_clause_style($connection_name);
    }

Usage Example

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