Doctrine: String keys with Array hydration
Posted
by
BenV
on Stack Overflow
See other posts from Stack Overflow
or by BenV
Published on 2011-01-17T03:49:02Z
Indexed on
2011/01/17
3:53 UTC
Read the original article
Hit count: 296
According to their documentation, you should use Array hydration rather than record hydration when retrieving data for read-only purposes.
However, this means I have to access the attributes of the retrieved object using arrays and string keys:
$user['Phonenumbers'][0]['number']
instead of the OO style:
$user->PhoneNumbers[0]->number
Now I'm kinda new to PHP, but in other languages I've worked with the 2nd notation would be preferable because typos would be caught at compile time while typos in string literals would not be noticed until runtime. Does this apply to PHP/Doctrine?
© Stack Overflow or respective owner