Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ public function compileTableExists()
/**
* Compile the query to determine the list of columns.
*
* @param string $table
* @return string
*/
public function compileColumnListing($table)
public function compileColumnListing()
{
return "select column_name from information_schema.columns where table_name = '$table'";
return 'select column_name from information_schema.columns where table_schema = ? and table_name = ?';
}

/**
Expand Down
23 changes: 23 additions & 0 deletions src/Illuminate/Database/Schema/PostgresBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,27 @@ protected function getAllTables()
$this->grammar->compileGetAllTables($this->connection->getConfig('schema'))
);
}

/**
* Get the column listing for a given table.
*
* @param string $table
* @return array
*/
public function getColumnListing($table)
{
if (is_array($schema = $this->connection->getConfig('schema'))) {
$schema = head($schema);
}

$schema = $schema ? $schema : 'public';

$table = $this->connection->getTablePrefix().$table;

$results = $this->connection->select(
$this->grammar->compileColumnListing(), [$schema, $table]
);

return $this->connection->getPostProcessor()->processColumnListing($results);
}
}