我想在Zend写这个查询...请帮帮我......
SELECT DISTINCT substr(A.REPORTED_DATE,0,10) AS REPORTED_DATE , COUNT(DISTINCT A.ISSUE_ID) AS ISSUE_COUNT
FROM ABACUS_ISSUE A
JOIN ABACUS_ISSUE_HISTORY B ON A.ISSUE_ID = B.ISSUE_ID AND B.FIELD_ID = 2028
AND (
B.OLD_VALUE IN (2,13)
AND B.NEW_VALUE = 8 OR A.STATE IN(2,13,10)
)
WHERE
(
A.ISSUE_TYPE = 1
AND A.ISSUE_SUB_TYPE_ID = 10
)
AND PARENT_ISSUE_ID = -1
AND A.PROJECT_ID = 'Tullett'
答案 0 :(得分:2)
这样的事情应该有效:
$select = $db->select()
->from(
array('A' => 'ABACUS_ISSUE'),
array('DISTINCT substr(A.REPORTED_DATE,0,10) AS REPORTED_DATE', 'COUNT(DISTINCT A.ISSUE_ID) AS ISSUE_COUNT')
)
->join(
array('B' => 'ABACUS_ISSUE_HISTORY'),
'A.ISSUE_ID = B.ISSUE_ID AND B.FIELD_ID = 2028 AND ( B.OLD_VALUE IN (2,13) AND B.NEW_VALUE = 8 OR A.STATE IN(2,13,10) )',
array()
)
->where('A.ISSUE_TYPE = ?', 1)
->where('A.ISSUE_SUB_TYPE_ID = ?', 10)
->where('PARENT_ISSUE_ID = ?', -1)
->where('A.PROJECT_ID = ?', 'Tullett');
$rows = $select->query()->fetchAll();
请阅读the docs。