Doctrine 1
  1. Doctrine 1
  2. DC-967

Problems with fetchArray() combined with leftJoin() by using aliases of columns

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      Symfony Framework v1.3.8, Windows 7

      Description

      They are some strange problems with hydration to array combined with aliases of columns and JOINS. Let's see this example:

      $q = Doctrine_Query::create ()
      ->select('c.id AS id, c.path AS path, c.name AS name, cbc.product_count')
      ->from('Category c')
      ->leftJoin('c.CategoryBrowserCache cbc');
      
      $categories = $q->fetchArray();
      

      This example will throw exception: "The root class of the query (alias lc) must have at least one field selected."

      OK. Let's change code a little bit. Let's add alias for cbc.product_count column too:

      $q = Doctrine_Query::create ()
      ->select('c.id AS id, c.path AS path, c.name AS name, cbc.product_count AS product_count')
      ->from('Category c')
      ->leftJoin('c.CategoryBrowserCache cbc');
      
      $categories = $q->fetchArray();
      print_r($categories);
      

      Now code executed without exception, BUT $q->fetchArray() returned only ONE (first) record hydrated to array. Other results were ignored.

      Let's change code one more time:

      $q = Doctrine_Query::create ()
      ->select('c.id, c.path, c.name, cbc.product_count AS product_count')
      ->from('Category c')
      ->leftJoin('c.CategoryBrowserCache cbc');
      $categories = $q->fetchArray();
      print_r($categories);
      

      Like you see I just removed all aliases for columns for Category. Now code will be executed without exceptions, All results will be hydrated into array as expected to be. Actually the same result can be reached by removing at least one alias for any Category column.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Arnoldas Lukasevicius
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: