cakephp - 获取表名称及其列详细信息 [英] cakephp - get table names and its column details
本文介绍了cakephp - 获取表名称及其列详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人知道如何从模型名称获取表名?另外,我想获得所有列名称及其类型的模型/表名称。是否可以获取给定型号名称的详细信息?
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?
感谢。
推荐答案
表名
要获取表,请参阅
$this->Model->table
类变量 $ useTable
的模型。如果这是未定义,那么你可以从模型的名称推断它:
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.
列
查看Model类的模式方法。例如:
Take a look at the schema method of the Model class. For example:
var_dump($this->Model->schema());
这篇关于cakephp - 获取表名称及其列详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文