Doctrine 1
  1. Doctrine 1
  2. DC-415

HYDRATE_ARRAY_HIERARCHY does not return array (returns Doctrine_Collection)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Nested Set
    • Labels:
      None
    • Environment:
      Vista Ultimate / Apache 2.2.8 / PHP5.2.4 / Symfony 1.4

      Description

      When hydration type is specified as HYDRATE_ARRAY_HIERARCHY, the result is a Doctrine_Collection rather than an array.

      Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      // The Category table is a typical NestedSet of shopping categories (definition below)
      $categories = Doctrine_Core::getTable('Category')
        ->findByDql('name LIKE ? OR name LIKE ?', array("$q%", "% $q%"), Doctrine_Core::HYDRATE_RECORD_HIERARCHY);
      
      // This should return bool(true), but returns bool(false)
      echo var_dump(is_array($categories));
      
      // This should return null, but returns Doctrine_Collection
      echo get_class($categories);
      
      Unable to find source-code formatter for language: yaml. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      # the category table definition (see attachment for data)
      Category:
        actAs:
          NestedSet: { hasManyRoots: true, rootColumnName: root_id }
        columns:
          category_id: { type: integer, unsigned: true, primary: true, autoincrement: true }
          name: { type: string(100), notnull: true }
          description: clob
      

      Note that this issue was opened for 1.2.0-BETA2 (DC-237) but was resolved as unable to reproduce. However, I can confirm that this issue still exists.

        Activity

        Hide
        Anush Ramani added a comment -

        I feel a bit silly... HYDRATE_ARRAY_HIERARCHY works as expected. I was using HYDRATE_RECORD_HIERARCHY.

        Show
        Anush Ramani added a comment - I feel a bit silly... HYDRATE_ARRAY_HIERARCHY works as expected . I was using HYDRATE_RECORD_HIERARCHY.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Anush Ramani
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: