Retrieving tables within your Cake database
Saturday, January 16th 2010, 1:04am
Topics: Tutorials, CakePHP
Tags: Manager, Database, Table, Show, List, Sources, Connection
Comments: 2
Permalink -
Tinylink
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.
Very handy, and a lot easier then writing a custom query with execute().
$db = ConnectionManager::getDataSource('default'); $tables = $db->listSources();
Very handy, and a lot easier then writing a custom query with execute().
2 Comments
Jan 16th 2010, 14:45
I always use it when I want to implement my old (non-CakePHP) database class singleton in CakePHP
mysiteonline.org
Jan 19th 2010, 08:55