我有这个SQL查询
SELECT COUNT( testRunID ) , platform, SUM( IF( STATUS = 'passed', 1, 0 ) ) passed_count,
SUM( IF( STATUS = 'failed', 1, 0 ) ) failed_count,
SUM( IF( STATUS = 'incomplete', 1, 0 ) ) incomplete_count
FROM tooldata
GROUP BY platform
ORDER BY platform
我在pdo写作时遇到了麻烦。我如何在三个不同的数组中输出incomplete_count,failed_count,passed_count? 伙计们帮助我。我是php和pdo的新手。
答案 0 :(得分:0)
我不应该回答这个问题,但看到这么多重复,我应该给你答案,这样你就不会再发帖了 - 这样做 -
$status = 'failed';
$allTest = $conn->prepare('SELECT SUM( IF( STATUS = :status, 1, 0 ) ) passed_count FROM tooldata GROUP BY platform ORDER BY platform' );
$allTest->execute(array(':status' => $status));
然后对 - $status = 'passed'; $status = 'incomplete';