Doctrine 1
  1. Doctrine 1
  2. DC-872

1.2 Documentation on Aggregate Functions Error


    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:


      In the documentation for using aggregate values with Doctrine Query (link below), there is a code snippet that shows how to access the value of the aggregate field, which does not work.

      The code snippet is:

      //firstsnippet after header
      $q = Doctrine_Query::create()
      ->select(', COUNT( AS num_threads')
      ->from('User u, u.Threads t')
      ->where(' = ?', 1)

      //second snippet after header
      $users = $q->execute();

      //fourth snippet after header
      echo $users->num_threads . ' threads found';

      The code from the last snippet for accessing the count value, $users->num_threads, doesn't seem to work. What does work for me is:

      //access count value
      echo $users[0]->num_threads

      //My exact code is:
      $query = Doctrine_Query::create()
      ->select('COUNT as batchCount')
      $result = $query->execute();

      echo $result->batchCount; //10
      echo $result[0]->batchCount; //3 (3 is correct, from direct MySQL command line query)

      It's certainly possible I'm doing something wrong, or that there is a Doctrine_Core attribute I need to set. If there is a Doctrine_Core attribute to set to automatically access aggregate values from the Collection, it would be worth noting at the top of the section.

      Thanks, and thanks for Doctrine (so awesome).



        There are no comments yet on this issue.


          • Assignee:
            Jonathan H. Wage
            Isaac Foster
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: