开发者

cakephp - get table names and its column details

开发者 https://www.devze.com 2023-04-12 02:07 出处:网络
Does anyone knows how to get table name from model name? Also I want to get all column names and its types of that model/table name. Is it possible to get such details of given model name?

Does anyone knows how to get table name from model name? Also I want to get all column names and its types of that model/table name. Is it possible to get such details of given model name?

Tha开发者_Go百科nks.


Table Name

To get the table, see

$this->Model->table

Or check the model for the class variable $useTable. If that's undefined, then you can infer it from the name of the model:

$tableName = Inflector::tableize($this->Model->alias);

See the Inflector documentation for similarly useful methods.

Columns

Take a look at the schema method of the Model class. For example:

var_dump($this->Model->schema());
0

精彩评论

暂无评论...
验证码 换一张
取 消