你好我有一个有效的查询,但我对Zend有点新手如何将下面的查询更改为zend查询?
SELECT
user_dob,
user_dob + INTERVAL(YEAR(CURRENT_TIMESTAMP) - YEAR(user_dob)) + 0 YEAR AS currbirthday
FROM user
ORDER BY CASE WHEN currbirthday < CURRENT_TIMESTAMP
THEN currbirthday + INTERVAL 1 YEAR
ELSE currbirthday
END
LIMIT 4
答案 0 :(得分:0)
$select = $sql->select ('user');
$select->columns(array(
'user_dob',
'currbirthday' => new Expression('user_dob + INTERVAL(YEAR(CURRENT_TIMESTAMP) - YEAR(user_dob)) + 0 YEAR')))
->order (
new Expression('
CASE WHEN currbirthday < CURRENT_TIMESTAMP
THEN currbirthday + INTERVAL 1 YEAR
ELSE currbirthday
END'
)
);