1212 */
1313class Builder extends \Illuminate \Database \Schema \Builder
1414{
15-
1615 /**
1716 * Determine if the given table exists.
1817 *
19- * @param string $table
18+ * @param string $table
2019 *
2120 * @return bool
2221 */
@@ -27,30 +26,49 @@ public function hasTable($table)
2726
2827 if (count ($ schemaTable ) > 1 ) {
2928 $ schema = $ schemaTable [0 ];
30- $ table = $ this ->connection ->getTablePrefix (). $ schemaTable [1 ];
29+ $ table = $ this ->connection ->getTablePrefix () . $ schemaTable [1 ];
3130 } else {
3231 $ schema = $ this ->connection ->getDefaultSchema ();
33- $ table = $ this ->connection ->getTablePrefix (). $ table ;
32+ $ table = $ this ->connection ->getTablePrefix () . $ table ;
3433 }
3534
36- return count ($ this ->connection ->select ($ sql , [$ schema , $ table ])) > 0 ;
35+ return count ($ this ->connection ->select ($ sql , [
36+ $ schema ,
37+ $ table ,
38+ ])) > 0 ;
3739 }
3840
3941 /**
4042 * Get the column listing for a given table.
4143 *
42- * @param string $table
44+ * @param string $table
4345 *
4446 * @return array
4547 */
4648 public function getColumnListing ($ table )
4749 {
4850 $ sql = $ this ->grammar ->compileColumnExists ();
4951 $ database = $ this ->connection ->getDatabaseName ();
50- $ table = $ this ->connection ->getTablePrefix ().$ table ;
51- $ results = $ this ->connection ->select ($ sql , [$ database , $ table ]);
52+ $ table = $ this ->connection ->getTablePrefix () . $ table ;
53+
54+ $ tableExploded = explode ('. ' , $ table );
55+
56+ if (count ($ tableExploded ) > 1 ) {
57+ $ database = $ tableExploded [0 ];
58+ $ table = $ tableExploded [1 ];
59+ }
60+
61+ $ results = $ this ->connection ->select ($ sql , [
62+ $ database ,
63+ $ table ,
64+ ]);
65+
66+ $ res = $ this ->connection ->getPostProcessor ()
67+ ->processColumnListing ($ results );
5268
53- return $ this ->connection ->getPostProcessor ()->processColumnListing ($ results );
69+ return array_values (array_map (function ($ r ) {
70+ return $ r ->column_name ;
71+ }, $ res ));
5472 }
5573
5674 /**
@@ -73,8 +91,8 @@ protected function build(Blueprint $blueprint)
7391 /**
7492 * Create a new command set with a Closure.
7593 *
76- * @param string $table
77- * @param \Closure $callback
94+ * @param string $table
95+ * @param \Closure $callback
7896 *
7997 * @return \Cooperl\DB2\Database\Schema\Blueprint
8098 */
0 commit comments