Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.5
    • Fix Version/s: 3.0
    • Component/s: ORM
    • Security Level: All

      Description

      The Doctrine\ORM\Internal\Hydration\ArrayHydrator ( https://github.com/doctrine/doctrine2/blob/85fbf684363b932a4ebaf543ef059f9ee1e512b0/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php ) is currently very messy and complicated due to the lack of actual Doctrine\ORM\UnitOfWork references when working with it, since we are not dealing with objects.

      In order to reduce the amount of bugs and code duplication when working with array hydration, I would simply suggest making use of the Doctrine\ORM\Internal\Hydration\ObjectHydrator ( https://github.com/doctrine/doctrine2/blob/85fbf684363b932a4ebaf543ef059f9ee1e512b0/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php ) and its siblings, and then extracting data coming from the results in it as an array.

      This could be a simple reflection-based extraction (pseudo):

      class ArrayHydrator
      {
          public function hydrateAllData()
          {
              foreach ($this->objectHydrator->hydrateAllData() as $object) {
                  yield $this->extractData($object);
              }
          }
      }
      

      The point here is that array-based hydration is not the primary focus of the ORM, and users should probably rely on SQL only when they want array hydration.

        Activity

        Hide
        Marco Pivetta added a comment - - edited

        Note: performance is one of our biggest requirements, and array hydration is meant to achieve that. As I stated above, plain SQL is probably better for this sort of operation, so the issue is more about deprecating the ArrayHydrator completely, providing utilities to manipulate SQL resultsets instead.

        Show
        Marco Pivetta added a comment - - edited Note: performance is one of our biggest requirements, and array hydration is meant to achieve that. As I stated above, plain SQL is probably better for this sort of operation, so the issue is more about deprecating the ArrayHydrator completely, providing utilities to manipulate SQL resultsets instead.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Marco Pivetta
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: