SQL to Doctrine query not working - Symphony 1.2

192 Views Asked by At

I'm trying to correct the query to have the correct amount of transaction from a symfony 1.2 APP.

The raw MYSQL query look like this

SELECT SUM(transaction.amount) AS 'CA CASSABLANCA'
FROM transaction , reservation , sf_guard_user_profile, center
WHERE reservation_id = reservation.id 
AND  reservation.sf_guard_user_profile_id = sf_guard_user_profile.id 
AND sf_guard_user_profile.center_id = center.id 
AND center.id = 7;

I'm trying to execute the query and get the result like this

$statement = Doctrine_Manager::getInstance()->connection();
$results = $statement->execute("SELECT SUM(transaction.amount) AS 'CA CASSABLANCA'
                FROM transaction , reservation , sf_guard_user_profile, center
                WHERE reservation_id = reservation.id 
                AND  reservation.sf_guard_user_profile_id = sf_guard_user_profile.id 
                AND sf_guard_user_profile.center_id = center.id 
                AND center.id = 7;");
$ca_t_center = (count($results) > 0) ? (double)$results : 0;
$this->getUser()->setAttribute("ca_center", $results);

But it's does not seem to work, do you see where the problem could be ?

0

There are 0 best solutions below