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?
有谁知道如何从型号名称获取表名?此外,我想获取该模型/表名称的所有列名称及其类型。是否有可能获得给定型号名称的详细信息?
Thanks.
谢谢。
1 个解决方案
#1
8
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:
或者检查模型中的类变量$ useTable。如果那是未定义的,那么你可以从模型的名称推断它:
$tableName = Inflector::tableize($this->Model->alias);
See the Inflector documentation for similarly useful methods.
有关类似的有用方法,请参阅Inflector文档。
Columns
列
Take a look at the schema method of the Model class. For example:
看一下Model类的schema方法。例如:
var_dump($this->Model->schema());
#1
8
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:
或者检查模型中的类变量$ useTable。如果那是未定义的,那么你可以从模型的名称推断它:
$tableName = Inflector::tableize($this->Model->alias);
See the Inflector documentation for similarly useful methods.
有关类似的有用方法,请参阅Inflector文档。
Columns
列
Take a look at the schema method of the Model class. For example:
看一下Model类的schema方法。例如:
var_dump($this->Model->schema());