- Implements timezone support. - Implements schema/searchPath support. For more information on configuring the database connection, see the __construct() method.
See also: lithium\data\source\database\adapter\PostgreSql::timezone()
See also: lithium\data\source\database\adapter\PostgreSql::searchPath()
See also: lithium\data\source\database\adapter\PostgreSql::__construct()
Inheritance: extends lithium\data\source\Database
Exemplo n.º 1
0
 /**
  * Tests that this adapter can connect to the database, and that the status is properly
  * persisted.
  */
 public function testDatabaseConnection()
 {
     $db = new PostgreSql(array('autoConnect' => false) + $this->_dbConfig);
     $this->assertTrue($db->connect());
     $this->assertTrue($db->isConnected());
     $this->assertTrue($db->disconnect());
     $this->assertFalse($db->isConnected());
     $db = new PostgreSql(array('autoConnect' => false, 'encoding' => null, 'persistent' => false, 'host' => 'localhost:5432', 'login' => 'garbage', 'password' => '', 'database' => 'garbage', 'init' => true, 'schema' => 'garbage') + $this->_dbConfig);
     $this->expectException();
     $this->assertFalse($db->connect());
     $this->assertFalse($db->isConnected());
     $this->assertTrue($db->disconnect());
     $this->assertFalse($db->isConnected());
 }
 /**
  * Skip the test if a MySQL or PostgreSQL adapter configuration is unavailable and
  * preload test data.
  */
 public function skip()
 {
     $enabled = MySql::enabled() || PostgreSql::enabled();
     $this->skipIf(!$enabled, 'MySQL or PostgreSQL Extension is not loaded');
     $dbConfig = Connections::get('test', array('config' => true));
     $validAdapter = in_array($dbConfig['adapter'], array('MySql', 'PostgreSql'));
     $hasDb = isset($dbConfig['adapter']) && $validAdapter;
     $message = 'Test database is either unavailable, or not using a MySQL/PostgreSQL adapter';
     $this->skipIf(!$hasDb, $message);
     switch ($dbConfig['adapter']) {
         case "MySql":
             $this->db = new MySql($dbConfig);
             $this->mockPrefix = 'mysql';
             break;
         case "PostgreSql":
             $this->db = new PostgreSql($dbConfig);
             $this->mockPrefix = 'postgresql';
             break;
     }
 }
 public function testConnectionGetAndReset()
 {
     Connections::add('conn-test', $this->config);
     Connections::add('conn-test-2', $this->config);
     $this->assertEqual(array('conn-test', 'conn-test-2'), Connections::get());
     $enabled = MySql::enabled() || PostgreSql::enabled();
     $this->skipIf(!$enabled, 'MySql or PostgreSQL is not enabled');
     if (MySql::enabled()) {
         $this->_port = 3306;
     }
     if (PostgreSql::enabled()) {
         $this->_port = 5432;
     }
     $msg = "Cannot connect to localhost:{$this->_port}";
     $this->skipIf(!$this->_canConnect('localhost', $this->_port), $msg);
     $expected = $this->config + array('type' => 'database', 'filters' => array());
     $this->assertEqual($expected, Connections::get('conn-test', array('config' => true)));
     $this->assertNull(Connections::reset());
     $this->assertFalse(Connections::get());
     $this->assertTrue(is_array(Connections::get()));
 }
Exemplo n.º 4
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     $this->connection = $this;
 }
 public function testEnabledFeatures()
 {
     $this->assertTrue(PostgreSql::enabled());
     $this->assertTrue(PostgreSql::enabled('relationships'));
     $this->assertFalse(PostgreSql::enabled('arrays'));
 }