Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2133

Issue with Query::iterate and query mixed results

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: 3.0
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Consider this code:

      $dql = "
          SELECT Page, Product.name
          FROM Dlayer\\Entity\\Page Page
          INNER JOIN Page.Product Product
          ";
      $q = ($em->createQuery($dql));
      foreach ($q->iterate() as $entry) {
        $page = $entry[0][0];
        $name = $entry[0]['name'];
      }
      

      This results with undefined index: 'name' for the second entry.

      First result keys are (notice just one array element with index 0):

      0
      array(2) {
        [0] =>
        int(0)
        [1] =>
        string(4) "name"
      } 
      

      but all others are different (notice two array elements with index 0 and the other one that is incrementing):

      the second one:
      0
      array(1) {
        [0] =>
        int(0)
      }
      1
      array(1) {
        [0] =>
        string(4) "name"
      } 
      the third one:
      0
      array(1) {
        [0] =>
        int(0)
      }
      2
      array(1) {
        [0] =>
        string(4) "name"
      } 
      
      

      What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method?

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

          This is a known issue that we don't have found a BC fix for and as I understand Guilherme Blanco requires considerable refactoring.

          Show
          Benjamin Eberlei added a comment - This is a known issue that we don't have found a BC fix for and as I understand Guilherme Blanco requires considerable refactoring.

            People

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

              Dates

              • Created:
                Updated: