symfony 原则分页带来的数据多于每页设置的数据
我在 symfony pager 中设置每页 1 行,但它显示的数据多于 1 行。这是因为我的查询将 sfGuardUser 表与其他表连接在一起,并且在某些情况下,当存在多个条目时,会导致“sfGuardUser”行重复在该特定用户的“许可证”表中!这是我的查询:
$pager = new sfDoctrinePager('sfGuardUser', '1');
$q = Doctrine_Query::create()
->select('u.id, u.username, g.name, l.id, l.status, l.client_id, l.vendor_id, l.applied_date, p.org_name')
->from('sfGuardUser u')
->leftJoin('u.Profile p')
->leftJoin('u.Groups g')
->leftJoin('u.LicensedClients l')
->where('g.name = \'vendor\'')
->orderBy('l.applied_date');
$q->setHydrationMode(Doctrine_Core::HYDRATE_SCALAR);
$pager->setQuery($q);
$pager->setPage($request->getParameter('page', 1));
$pager->init();
分页是存在的,但问题是在某些情况下,当许可证表中某个特定用户有多行时,一页中会显示多行。我怎样才能以正确的方式实施它?
I am setting 1 row per page in symfony pager but its showing more data than 1. It is because my query is left joining the sfGuardUser table with other tables and it is causing duplication of 'sfGuardUser' row in some cases when there are multiple entries in 'license' table for that particular user ! Here is my query:
$pager = new sfDoctrinePager('sfGuardUser', '1');
$q = Doctrine_Query::create()
->select('u.id, u.username, g.name, l.id, l.status, l.client_id, l.vendor_id, l.applied_date, p.org_name')
->from('sfGuardUser u')
->leftJoin('u.Profile p')
->leftJoin('u.Groups g')
->leftJoin('u.LicensedClients l')
->where('g.name = \'vendor\'')
->orderBy('l.applied_date');
$q->setHydrationMode(Doctrine_Core::HYDRATE_SCALAR);
$pager->setQuery($q);
$pager->setPage($request->getParameter('page', 1));
$pager->init();
The pagination is there, but problem is in some cases there are multiple rows shown in one page when there are multiple rows for a particular user in the license table. How can I implement it in a right way ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当分页 (sfGuard)Users 时,您希望通过连接用户和许可证表(1:n 关系)来实现什么?
如果您想按许可证类型/日期/计数对用户进行排序,您可以使用
What do you want to achieve with joining user and license table (1:n relation) when paging through (sfGuard)Users ?
If you want to sort users by license type/date/count, you could use