set_db() 공개 정적인 메소드

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
예제 #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);
 }
예제 #2
0
 public function setUp()
 {
     // Set up the dummy database connections
     ORM::set_db(new MockPDO('sqlite::memory:'));
     ORM::set_db(new MockDifferentPDO('sqlite::memory:'), self::ALTERNATE);
     // Enable logging
     ORM::configure('logging', true);
     ORM::configure('logging', true, self::ALTERNATE);
 }
예제 #3
0
 public function tearDown()
 {
     ORM::configure('logging', false);
     ORM::set_db(null);
     ORM::configure('id_column', 'id');
 }