Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp get schema for list of tables

Tags:

cakephp

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

like image 222
LordZardeck Avatar asked Dec 22 '22 02:12

LordZardeck


1 Answers

Get a datasource, by:

$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 a table, say "products"

$db->describe('products');

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

like image 128
ori Avatar answered Jan 15 '23 02:01

ori