/** * tearDownAfterClass * * @return void */ public static function tearDownAfterClass() { if (!static::$dbo) { return; } if (!static::$debug) { try { static::$dbo->setQuery(PostgresqlQueryBuilder::dropTable('#__cloud', true))->execute(); } catch (\Exception $e) { // Do nothing } try { static::$dbo->setQuery(PostgresqlQueryBuilder::dropTable('#__wind', true))->execute(); } catch (\Exception $e) { // Do nothing } } parent::tearDownAfterClass(); }
/** * Method to test getQuery(). * * @return void * * @covers Windwalker\Query\Postgresql\PostgresqlQueryBuilder::getQuery */ public function testGetQuery() { $this->assertInstanceOf('Windwalker\\Query\\Postgresql\\PostgresqlQuery', PostgresqlQueryBuilder::getQuery()); $this->assertSame(PostgresqlQueryBuilder::getQuery(), PostgresqlQueryBuilder::getQuery()); $this->assertNotSame(PostgresqlQueryBuilder::getQuery(), PostgresqlQueryBuilder::getQuery(true)); }
/** * 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(); }
/** * getColumnDetails * * @param bool $full * * @return mixed */ public function getColumnDetails($full = true) { $query = PostgresqlQueryBuilder::showTableColumns($this->db->replacePrefix($this->table), $full); $fields = $this->db->setQuery($query)->loadAll(); $result = array(); foreach ($fields as $field) { // Do some dirty translation to MySQL output. $result[$field->column_name] = (object) array('column_name' => $field->column_name, 'type' => $field->column_type, 'null' => $field->Null, 'Default' => $field->Default, 'Field' => $field->column_name, 'Type' => $field->column_type, 'Null' => $field->Null, 'Extra' => null, 'Privileges' => null, 'Comment' => $field->Comment); } $keys = $this->getIndexes(); foreach ($result as $field) { if (preg_match("/^NULL::*/", $field->Default)) { $field->Default = null; } if (strpos($field->Type, 'character varying') !== false) { $field->Type = str_replace('character varying', 'varchar', $field->Type); } if (strpos($field->Default, 'nextval') !== false) { $field->Extra = 'auto_increment'; } // Find key $index = null; foreach ($keys as $key) { if ($key->column_name == $field->column_name) { $index = $key; break; } } if ($index) { if ($index->is_primary) { $field->Key = 'PRI'; } elseif ($index->is_unique) { $field->Key = 'UNI'; } else { $field->Key = 'MUL'; } } } return $result; }
/** * getTableDetail * * @param bool $table * * @return mixed */ public function getTableDetail($table) { $table = $this->db->replacePrefix($table); $query = PostgresqlQueryBuilder::showDbTables($this->database, 'table_name = ' . $this->db->quote($table)); $table = $this->db->setQuery($query)->loadOne(); if (!$table) { return false; } return $table; }