2
当通过数据对象orm查询数据库时,记录如何通过页面父项的属性进行过滤?Silverstripe按父页属性筛选
所以,我心目中是这样的:
$facilities_by_keyword = Facility::get()->filter('Parent.tags:partialmatch', $tag);
当通过数据对象orm查询数据库时,记录如何通过页面父项的属性进行过滤?Silverstripe按父页属性筛选
所以,我心目中是这样的:
$facilities_by_keyword = Facility::get()->filter('Parent.tags:partialmatch', $tag);
你能先取得所有父页面。然后得到任何这些父页的孩子的设施页面:
$parentPages = Page::get()->filter('Parent.tags:partialmatch', $tag);
$parentIDs = $parentPages->getIDList();
$facilities_by_keyword = Facility::get()->where('ParentID IN (' . implode(',', $parentIDs) . ')');
谢谢你。我想唯一担心的是做2个数据库查询的性能影响。虽然不错,但可读性差,不适合随身携带。 – Will