我正在尝试更正查询,以从symfony 1.2 APP中获得正确的交易量。
原始的MySQL查询如下所示
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;
我正在尝试执行查询并获得像这样的结果
$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);
但这似乎行不通,您知道问题出在哪里吗?