Aut*_*cus 17 php cakephp cakephp-1.3
我是CakePHP的新手.我想读取控制器中表的字段名称.
我希望控制器列出表中的所有字段名称.我怎么做?
dho*_*tet 26
使用以下代码段获取字段名称数组(将"YourModel"替换为模型名称):
array_keys($this->YourModel->getColumnTypes());
Run Code Online (Sandbox Code Playgroud)
对于CakePHP 3.x
$ this-> Model-> schema() -返回Schema对象。
$ this-> Model-> schema()-> columns() -返回数组中表中的所有列。