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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:53:15  来源:igfitidea点击:

Laravel php tinker command to show tables and structures?

phplaraveleloquent

提问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"');