从SQL到学说的查询不起作用-Symphony 1.2

时间:2018-12-17 16:41:47

标签: mysql doctrine symfony1

我正在尝试更正查询,以从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);

但这似乎行不通,您知道问题出在哪里吗?

0 个答案:

没有答案