<?php
$id = $user->getId();
$q = Doctrine_Query::create()
    ->select('d.debt_sum')
    ->from('Debt d')
    ->where('d.user_id=?', $id)
    ->execute();
//print_r($user);
$total_sum = 0;
foreach ($q as $row)
{
  $total_sum += $row['debt_sum'];
  /*print_r($row['debt_sum']);*/
}
echo $total_sum;
//echo $q->getDiscountValue() . ' %';
?>