php - Cakephp 查找转换为 Sql 语法

标签 php mysql sql cakephp cakephp-2.0

Cakephp在 Controller 中查找数据也可以使用sql语法,

示例:

$this->Post->find('all');

在 SQL 中:

select * from posts

将查询转换为 cakephp 查找语法可在 http://dogmatic69.com/sql-to-cakephp-find-converter 处找到。

但是如果我想将 cakephp find 转换为查询,是否有任何链接可供我使用。

提前致谢...

最佳答案

如果我明白你的问题,这就是答案

SQL calls that you can’t or don’t want to make via other model
methods can be made using the model’s query() method (though this
should only rarely be necessary).

query() 使用查询中的表名称作为返回数据的数组键,而不是模型名称。例如:

$this->POST->query("SELECT* from posts;");

这是 cakephp 的链接 documentation

关于php - Cakephp 查找转换为 Sql 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37018115/

相关文章:

mysql - 真的有必要在此查询中创建外键吗?

mysql - 如何使用 TSQl 从文件夹读取文件并将文件名保存到表中?

sql - 如何修复 SQL 错误 : ORA-00001: unique constraint (ALERTS2. PK_UP_MODULE_MASTER) violated

php - 如何以二进制形式获取 BIT(...) 数据类型列的值?

php - 如何提高网站开发技能?

php - Mysql:最近 7 天的结果

php - 数据库 :raw 产生不良结果

php - 使用 mySQL 中的数据填充 HTML DIV

php oops 包括另一个页面

C# ASP.NET、Azure 混合 SQL 连接无法连接到 Web 表单应用程序上的数据库