FuelPHP-订购多对多关系 [英] FuelPHP - Ordering Many to Many Relations
问题描述
我检查了文档,但似乎找不到我想要的东西. 我有两个桌子:
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]
成为状态为1的最新布局. 第一次引用布局时,模型中是否有条件多对多还是在Controller中执行?
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.
谢谢
推荐答案
您可以在关系定义中指定条件.目前,仅当您使用急切加载时才尊重这些,而懒加载则忽略.
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.
这篇关于FuelPHP-订购多对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!