cakephp获取表的列表的模式

编程入门 行业动态 更新时间:2024-10-24 06:25:58
本文介绍了cakephp获取表的列表的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在cakephp中有一个简单的方法来获取表模式的数组,以获取特定表的列表?例如,我想要一个表模式表a,b,d,f和z;

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?

推荐答案

获取一个数据源,通过:

Get a datasource, by:

$db =& ConnectionManager::getDataSource('default');

$db =& $this->User->getDataSource(); // or any other model

然后您可以通过调用以下方式获取所有表:

Then you can get all the tables by calling:

$db->listSources()

b $ b

获取表的模式,例如products

And get the schema for a table, say "products"

$db->describe('products');

但是,传递一个字符串到 describe 仅在CakePHP 2.0 中,1.3需要模型对象。

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

更多推荐

cakephp获取表的列表的模式

本文发布于:2023-10-18 12:53:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   列表   cakephp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!