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 function setUp()
 {
     // Enable logging
     ORM::configure('logging', true);
     // Set up the dummy database connection
     $db = new PDO('sqlite::memory:');
     ORM::set_db($db);
 }
 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);
 }
Beispiel #3
0
 public function testFindResultSetByDefault()
 {
     ORM::configure('return_result_sets', true);
     $result_set = ORM::for_table('test')->find_many();
     $this->assertInstanceOf('Granada\\ResultSet', $result_set);
     $this->assertSame(count($result_set), 5);
     ORM::configure('return_result_sets', false);
     $result_set = ORM::for_table('test')->find_many();
     $this->assertInternalType('array', $result_set);
     $this->assertSame(count($result_set), 5);
 }
Beispiel #4
0
 public function testLoggerCallback()
 {
     ORM::configure('logger', function ($log_string) {
         return $log_string;
     });
     $function = ORM::get_config('logger');
     $this->assertTrue(is_callable($function));
     $log_string = "UPDATE `widget` SET `added` = NOW() WHERE `id` = '1'";
     $this->assertEquals($log_string, $function($log_string));
     ORM::configure('logger', null);
 }
 public function tearDown()
 {
     ORM::configure('logging', false);
     ORM::setDb(null);
 }
Beispiel #6
0
 public function testGetConfig()
 {
     $this->assertTrue(ORM::get_config('logging'));
     ORM::configure('logging', false);
     $this->assertFalse(ORM::get_config('logging'));
     ORM::configure('logging', true);
 }