Retrieve custom columns in Symfony

Sometimes while retrieving data, you might not need all the columns, especially on a large database query result set.

Symfony, or actually Propel (1.3) allows you to chose what columns to retrieve, and skip the hydrate process:

// Custom column, on large subset
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(TitlePeer::ID);
$c->addSelectColumn(TitlePeer::TITLE);
$resTitleRS = TitlePeer::doSelectStmt($c);
// Loop through result and create custom array
while ($row = $resTitleRS->fetch(PDO::FETCH_ASSOC)) {
  $title_id = $row['ID'];
  $title_name = $row['TITLE'];
  $arrTitleDB[$title_id] = $title_name;
}