我正在尝试更正查询,以便从symfony1.2应用程序获得正确的交易量。
原始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);
但它似乎不起作用,你看到问题出在哪里了吗?
暂无答案!
目前还没有任何答案,快来回答吧!