5
我有一個正常的mysql選擇,我想重寫它到一個Zend Framework的mysql選擇。這是我的選擇:如何用IF重寫正常的sql選擇到Zend Framework select?
$sql = "
SELECT
IF(mu.recieverUserId = '{$userId}', u.senderUserId,
mu.recieverUserId) friend1,
u.mesaj, u.senderUserId, mu.recieverUserId,
u.created
FROM
(SELECT *
FROM mesaje
ORDER BY `created` desc) AS u
LEFT JOIN `mesaje_utilizatori` AS `mu` ON u.id=mu.mesajId
WHERE (mu.recieverUserId = '{$userId}' OR u.senderUserId='{$userId}')
GROUP BY friend1 ASC
ORDER BY `u`.`created` DESC, u.id DESC
";
這不是問路這個問題,這是別人正在解決你的問題,你正在努力它..你可以問如內部查詢如何在zend中工作,以及如何在zend選擇查詢中寫入條件 – Sahal
http://stackoverflow.com/questions/1340564/writing-a-subquery-using-zend-db .... http://stackoverflow.com/questions/5792229/zend-framework-zend-db-select-how-to-join-custom-subquery-表 – Sahal
完全重複的 http://stackoverflow.com/questions/5792229/zend-framework-zend-db-select-how-to-join-custom-subquery-table – Sahal