Laravel php tinker 命令显示表和结构?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37504120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel php tinker command to show tables and structures?
提问by The Man
What is he command within Laravels' php artisan tinker that shows tables and/or structure of those tables?
他在 Laravel 的 php artisan tinker 中命令什么来显示表格和/或这些表格的结构?
回答by Giedrius Kir?ys
To get all tables, use this:$tables = \DB::select('show tables');
.
要获得所有表,使用:$tables = \DB::select('show tables');
。
To get all columns of table, use this:$columns = \Schema::getColumnListing('<table_name>');
要获取表的所有列,请使用以下命令:$columns = \Schema::getColumnListing('<table_name>');
回答by STWilson
For sqlite, use:
对于 sqlite,请使用:
DB::select('SELECT NAME FROM sqlite_master WHERE type="table"');