dongzhuoxie1244 2011-09-07 12:17
浏览 72

symfony doctrine分页带来的数据多于每页设置的数据

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 ?

  • 写回答

1条回答 默认 最新

  • douyin4875 2011-09-09 21:36
    关注

    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

    DISTINCT u.id, u.username
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)