Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2220

Add joins to Collection Filtering API

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All

      Description

      The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      That would not work.

      Ideally we should have a possibility to join other entities, the Category entity in our case here:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->innerJoin(Criteria::expr()->field('Category', 'Category'))
              ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      What do you think about it, does it make sense to add such functionality?

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Oleg Namaka
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: