コード例 #1
0
 /**
  * Method to test dropDatabase().
  *
  * @return void
  *
  * @covers Windwalker\Query\Postgresql\PostgresqlQueryBuilder::dropDatabase
  */
 public function testDropDatabase()
 {
     $expected = "DROP DATABASE {$this->qn}foo{$this->qn}";
     $actual = PostgresqlQueryBuilder::dropDatabase('foo');
     $this->assertEquals(\SqlFormatter::compress($expected), \SqlFormatter::compress($actual));
     $expected = "DROP DATABASE IF EXISTS {$this->qn}foo{$this->qn}";
     $actual = PostgresqlQueryBuilder::dropDatabase('foo', true);
     $this->assertEquals(\SqlFormatter::compress($expected), \SqlFormatter::compress($actual));
 }
コード例 #2
0
 /**
  * Method to test dropDatabase().
  *
  * @return void
  *
  * @covers Windwalker\Query\Postgresql\PostgresqlQueryBuilder::dropDatabase
  */
 public function testDropDatabase()
 {
     $expected = "DROP DATABASE {$this->qn('foo')}";
     $actual = PostgresqlQueryBuilder::dropDatabase('foo');
     $this->assertEquals($this->format($expected), $this->format($actual));
     $expected = "DROP DATABASE IF EXISTS {$this->qn('foo')}";
     $actual = PostgresqlQueryBuilder::dropDatabase('foo', true);
     $this->assertEquals($this->format($expected), $this->format($actual));
 }
コード例 #3
0
 /**
  * dropDatabase
  *
  * @param bool $ifExists
  *
  * @return  static
  */
 public function drop($ifExists = false)
 {
     if ($this->getName() == $this->db->getDatabase()->getName()) {
         $this->db->disconnect();
         $this->db->setDatabaseName(null);
         $this->db->connect();
     }
     $pid = version_compare($this->db->getVersion(), '9.2', '>=') ? 'pid' : 'procpid';
     $query = $this->db->getQuery(true);
     $query->select('pg_terminate_backend(' . $pid . ')')->from('pg_stat_activity')->where('datname = ' . $query->quote($this->getName()));
     $this->db->setQuery($query)->execute();
     $query = PostgresqlQueryBuilder::dropDatabase($this->database, $ifExists);
     $this->db->setQuery($query)->execute();
     return $this;
 }
コード例 #4
0
 /**
  * tearDownAfterClass
  *
  * @return  void
  */
 public static function tearDownAfterClass()
 {
     static::$dbo->setQuery(PostgresqlQueryBuilder::dropDatabase('windwalker_foo_test', true))->execute();
     static::$dbo->setQuery(PostgresqlQueryBuilder::dropDatabase('windwalker_bar_test', true))->execute();
     parent::tearDownAfterClass();
 }