递归模型不会在蛋糕壳中使用 find('all') 或 read(null, id) 加载
我无法访问 cakephp shell 中的递归模型。
MyModel 的数据已加载,但未执行联接。当使用相同的 MyModel 和来自控制器的关联时,将执行连接并加载数据。
有人遇到过这个问题吗?
I cannot get access to recursive models in my cakephp shell.
The data of MyModel are loaded, but joins are not performed. When using the same MyModel and associations from a controller, joins are performed and data is loaded.
Does anybody experienced this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以根据所需的数据量将 $recursive 设置为不同的值。想象一下您的应用程序具有属于某个域的组,并拥有许多用户,而这些用户又拥有许多文章
。然后将其设置为不高于您的需要。让 CakePHP 获取您不会使用的数据会不必要地减慢您的应用程序。另请注意,默认递归级别为 1。
You can set $recursive to different values based on the amount of data you want.Imagine your application features Groups which belong to a domain and have many Users which in turn have many Articles.Then
Set it no higher than you need. Having CakePHP fetch data you aren’t going to use slows your app unnecessarily. Also note that the default recursive level is 1.
问题来自我正在使用的 $uses:
在控制器中我有:
在 shell 中我有:
Cakephp 即使不引用插件也能够找到模型,但它无法找到 HABTM 模型。
The problem was comming from the $uses I was using:
In controller I had:
In shell I had:
Cakephp was able to find the model even without reference to the plugin, but it failed to find HABTM ones.