Cakephp gets schema for table list

Is there an easy way in cakephp to get an array of table schemas for a list of specific tables? For example, I need a table schema for tables a, b, d, f, and z; Also, is there a way to get an array of schemas from all tables?

+2
source share
2 answers

Get data source:

$db =& ConnectionManager::getDataSource('default');

or

$db =& $this->User->getDataSource(); // or any other model 

Then you can get all the tables by calling:

$db->listSources()

And get the schema for the table, say, "products"

$db->describe('products');

However, passing a string in describe only in CakePHP 2.0 , 1.3 requires a model object.

+7
source

try it

pr($this->Model->schema());
+3
source

All Articles