2017-05-30 38 views
0

标题说,有没有办法从多个表中选择列名?list_columns()多表?

DB::list_columns('table1'); //returns columns of table1 

我想要做的就是

DB::list_columns('table1', 'table2'); 

我要选择2个或多个表中的所有列。 有可能吗?

+2

不,从快速浏览文档看起来并不像它。但是,因为所有这些都返回一个数组,所以调用它两次应该不是什么大问题,然后将结果合并到一个必要的数组中。 – CBroe

+0

'list_columns($ table,$ like = null,$ db = null)' - > ** table ** and _not tables_ – Thamilan

回答

0

使用DB::list_tables()中的foreach读取使用DB::list_columns($current_table)

如果使用PDO_Connection,这是不支持的当前表。

0

感谢那些谁回答说,这里是我做过什么

$col1 = DB::list_columns('table1'); 

foreach ($col1 as $key => $value) { 
    array_push($columns['col1'], $key); 
} 

$col2 = DB::list_columns('table2'); 

foreach ($col2 as $key => $value) { 
    array_push($columns['col2'], $key); 
} 

$colnames = array_merge($col1, $col2); 

@CBroe感谢给我的想法!