Skip to content

Commit 23bf478

Browse files
committed
fix(builder): fix getColumnListing
1 parent f8640dc commit 23bf478

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/Database/Schema/Builder.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,26 @@ public function getColumnListing($table)
4747
{
4848
$sql = $this->grammar->compileColumnExists();
4949
$database = $this->connection->getDatabaseName();
50-
$table = $this->connection->getTablePrefix().$table;
51-
$results = $this->connection->select($sql, [$database, $table]);
50+
$table = $this->connection->getTablePrefix() . $table;
5251

53-
return $this->connection->getPostProcessor()->processColumnListing($results);
52+
$tableExploded = explode('.', $table);
53+
54+
if (count($tableExploded) > 1) {
55+
$database = $tableExploded[0];
56+
$table = $tableExploded[1];
57+
}
58+
59+
$results = $this->connection->select($sql, [
60+
$database,
61+
$table,
62+
]);
63+
64+
$res = $this->connection->getPostProcessor()
65+
->processColumnListing($results);
66+
67+
return array_values(array_map(function($r) {
68+
return $r->column_name;
69+
}, $res));
5470
}
5571

5672
/**

0 commit comments

Comments
 (0)