<?php
$id = $user->getId();
$q = Doctrine_Query::create()
    ->select('d.debt_sum')
    ->from('Debt d')
    ->where('d.user_id=?', $id)
    ->andWhere('d.deadline < NOW()')
    ->execute();
$overdue_sum = 0;
foreach ($q as $row)
{
  $overdue_sum += $row['debt_sum'];
}
echo $overdue_sum;

?>