Php/Doctrine array hydration According to the Doctrine docs, you should use Array hydration rather than record hydration when retrieving data for read-only purposes.

Unfortunately, this means I have to use array syntax (as opposed to object syntax) to reference the data.

$q = Doctrine_Query::create()
    -&gt;from('Post p')
    -&gt;leftJoin('p.PostComment pc')
    -&gt;leftJoin('pc.User u')
    -&gt;where('p.post_id = ?', $id);

$p = $q-&gt;fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);

...

foreach ($p['PostComment'] as $comment) {
    $this-&gt;Controls-&gt;Add(new CommentPanel($comment['text'], 
                         $comment['User']['nickname'], 
                         $comment['last_updated_ts']));
}


Maybe it's just me, but all of those string literals as array indexes are kinda scary.  Does anyone have some ideas for cleaning this up?
Scary?  In what way?  I don't really get that.

It's just syntax.  If you really care, just cast the arrays as stdClass objects

foreach ( $p['PostComment'] as $comment )
{
  $comment = (object) $comment;
  $this-&gt;Controls-&gt;Add( new CommentPanel(
      $comment-&gt;text
    , $comment-&gt;User-&gt;nickname
    , $comment-&gt;last_updated_ts
  ));
}