Doctrine 1
  1. Doctrine 1
  2. DC-220

Array Hydration could hydrate some custom getters

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.1.5
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None

      Description

      Array Hydration, used for displaying especially, has great benefits (performance) but it has also a great drawback : impossible to use custom getters or methods on it.
      But often, custom getters are really useful : think of a "vat" and a "ve_price" fields in the DB, and a getViPrice() custom getter to calculate VAT inc. price.
      This a straightforward example, but you can also think of a value calculated from a parent of the record (e.g. ), of a statistic on its children (let's say Artist::getUnavailableAlbumsCount())

      All those methods have something in common : they modify nothing, they are only highly useful helpers, but they cannot be present in hydrated Arrays.

      In my case, I rarely use Array hydration, just because of that drawback. It's a major benefit of ORMs that disappears as soon as your hydrate Arrays !

      Thus, my suggestion is: why not permit, while hydrating arrays, to add qualified custom accessors results to hydrated values ? It would be quite easy to implement, I think ?

        Activity

        Hide
        Jonathan H. Wage added a comment -

        The point of array hydration is that it uses arrays and not the objects, so it is much faster. Doing this would make array hydration even slower than record hydration, negating the whole point.

        Show
        Jonathan H. Wage added a comment - The point of array hydration is that it uses arrays and not the objects, so it is much faster. Doing this would make array hydration even slower than record hydration, negating the whole point.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Benoît Guchet
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: