List all tables in cakePHP 3.x

最后都变了- 提交于 2020-01-03 15:37:17

问题


I have been trying to work this one out. In cakePHP 2 I could use:

$tables = ConnectionManager::getDataSource('default')->listSources();

But in CakePHP 3.x I can't work out what to use? I have looked at the link cakephp get schema for list of tables

Unfortunately it doesnt help with cakePHP 3.0?


回答1:


We can get list of table in cakephp3 using very similar pattern as

$tables = ConnectionManager::get('default')->schemaCollection()->listTables();



回答2:


I just had the same problem. Try using the code below

TableRegistry::exists($model);


来源:https://stackoverflow.com/questions/30255196/list-all-tables-in-cakephp-3-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!