模型是否可以链接到数据库中的视图而不是CakePHP中的表? [英] Can a model link to a View in the database instead of a table in CakePHP?

查看:100
本文介绍了模型是否可以链接到数据库中的视图而不是CakePHP中的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在数据库中创建一个视图,然后才能将一个模型链接到它。

I was wondering if it was possible to create a view in a database then be able to link a Model to it?

推荐答案

p>是的。有可能。

创建视图,就像它是一个表,并确保它遵守所有的蛋糕规则创建表。然后你可以创建一个模型,控制器和视图,就像任何其他表。它甚至出现在蛋糕烘焙应用程序作为一个普通的表。

Create the view as if it were a table and make sure that it adheres to all the cake rules for creating tables. Then you can create a model, controller and view as you would with any other Table. It even comes up in the cake bake app as a normal Table.

我发现的一个好的事情是处理分页/排序在一个非常规范的数据库,蛋糕变得几乎不可能处理。因此,您可以将所有复杂的联接合并到一个数据库查询中,然后将其巧妙地插入到一个表格上的分页/排序的世界中,这样的表格就像一个魅力。

One of the nice things I found was when dealing with pagination/sorting across a very normalised database, cake becomes almost impossible to deal with. Thus you can combine all your complex joins into one database query which then plugs nicely into cake's world of pagination/sorting on one table which works like a charm.

这篇关于模型是否可以链接到数据库中的视图而不是CakePHP中的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆