FuelPHP - Ordering Many to Many Relations

与世无争的帅哥 提交于 2019-12-11 05:17:11

问题


I checked the documentation, but can't seem to find what I'm looking for. I have two tables:

Pages Layouts

With a table between (pages__layouts) that does the many-to-many. This is working great. However, when referencing the relationship, I always want:

$p->layout[1]

To be the most recent layout that also has a status of 1. Is there a conditional many-to-many in the model or do I do this in the Controller when I reference the layout for the first time?

I have just been using lazy loading to get the layouts when I need them.

Thanks


回答1:


You can specify conditions on the relation definition. At the moment these are only honoured when you use eager loading, lazy loading ignores then.

There is an open ticket to get this fixed.



来源:https://stackoverflow.com/questions/10788210/fuelphp-ordering-many-to-many-relations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!