自定义分页器/ formfilter/ buildquery 不会将过滤器数据处理为查询
我有一个操作需要使用表单过滤器、分页器和特定的表方法:
$this->filterForm = new OrganisationFormFilter();
$this->filterForm->setTableMethod('retrieveMemberOrganisations');
$this->filterForm->bind($searchParams);
$v = $this->filterForm->getValues();
$q = $this->filterForm->buildQuery($v);
$this->pager = new sfDoctrinePager('Organisation', 50);
$this->pager->setQuery($q->orderBy(implode(' ',$this->getSort())));
$this->pager->setPage($request->getParameter('page',1));
$this->pager->init();
public function retrieveMemberOrganisations(Doctrine_Query $q){
$rootAlias = $q->getRootAlias();
$q->
select("$rootAlias.*")->
addSelect('m.id, sc.id, cat.id, cat.number_key')->
innerJoin ("$rootAlias.CurrentMember c")->
innerJoin ("$rootAlias.Membership m")->
innerJoin ('m.LatestMembership lm')->
innerJoin ('m.MembershipSubcategory sc')->
innerJoin ('sc.MembershipCategory cat');
return $q;
}
问题是过滤器设置根本没有被处理。我已经检查了 $v 中的值是否已设置,但它们似乎没有反映在 $q 中。此外,当我在进入retrieveMemberOrganizations 时使用调试器停止时,$q 也不限制过滤器设置。这是我使用的代码的正确顺序吗?
I have an action requiring to use a formfilter, pager and a specific table method:
$this->filterForm = new OrganisationFormFilter();
$this->filterForm->setTableMethod('retrieveMemberOrganisations');
$this->filterForm->bind($searchParams);
$v = $this->filterForm->getValues();
$q = $this->filterForm->buildQuery($v);
$this->pager = new sfDoctrinePager('Organisation', 50);
$this->pager->setQuery($q->orderBy(implode(' ',$this->getSort())));
$this->pager->setPage($request->getParameter('page',1));
$this->pager->init();
public function retrieveMemberOrganisations(Doctrine_Query $q){
$rootAlias = $q->getRootAlias();
$q->
select("$rootAlias.*")->
addSelect('m.id, sc.id, cat.id, cat.number_key')->
innerJoin ("$rootAlias.CurrentMember c")->
innerJoin ("$rootAlias.Membership m")->
innerJoin ('m.LatestMembership lm')->
innerJoin ('m.MembershipSubcategory sc')->
innerJoin ('sc.MembershipCategory cat');
return $q;
}
Problem is that the filter settings are not processed at all. I have checked that values in $v are set, but they don't seem to be reflected in $q. Also when I stop with a debugger on entry to retrieveMemberOrganisations, $q doesnt contrain the filter settings either. Is this the right order of code that I'm using?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实际上正在使用 formFilter 来做类似的事情。 而是使用
use ,但认为这应该可行。
我没有使用 setTableMethod 方法,
I'm actually using the formFilter to do something like that. Instead of using
use
I'm not using the setTableMethod method, but think that should work.