Retrieving tables within your Cake database
This article is over a year old and may contain outdated information.
I have been working lately on adding an installation process to my forum plugin. For this process I needed a way to retrieve a list of tables within a selected database, to make sure there are no table name conflicts. After asking the question on Twitter, I got the answer thanks to @pierremartin and @mark_story (of course!). You simply use the ConnectionManager class.
$db = ConnectionManager::getDataSource('default');
$tables = $db->listSources();
Very handy, and a lot easier then writing a custom query with execute().
2 Comments
I always use it when I want to implement my old (non-CakePHP) database class singleton in CakePHP