我如何在Yii ORM findAll
中使用CDbCriteria
来查找所有Users
模型
SELECT DISTINCT u.id, u.slug, IFNULL(MIN(m.id), 0) FROM tbl_users u
INNER JOIN tbl_status s ON (s.users_id = u.id AND s.accept > 0)
INNER JOIN tbl_message m ON (m.owner_id = s.receiver AND m.users_id = s.users_id)
WHERE u.free = 0 AND u.es_index_time <> 0 AND
u.paid = 1 AND u.withdrawed = 0 AND (
NOT EXISTS (SELECT 1 FROM tbl_users_prepay up WHERE up.users_id = u.id) OR
EXISTS (SELECT 1 FROM tbl_users_prepay up WHERE up.user_redirect_id = u.id)
)
GROUP BY u.id
LIMIT 6;
1条答案
按热度按时间5jdjgkvh1#