首页 > yii2 这条sql查询语句,查询应该怎么写

yii2 这条sql查询语句,查询应该怎么写

请问这条sql语句:select count(*) from token where 'user_id'=$tokenInfo['user_id'] and create_time > $tokenInfo['create_time'];
用yii2框架的查询方法,应该怎么写?我像下面这样写是错误的:

$newCount = Token::find()->where(
[

'user_id' => $tokenInfo['user_id'],
['>', 'create_time', $tokenInfo['create_time']]

])->count();

请知道的指教下我,先谢谢了!!!


$newCount = Token::find()->where(
    ['user_id' => $tokenInfo['user_id']])->andWhere([
    ['>', 'create_time', $tokenInfo['create_time']]
    ])->count();

或者

User::find()->where(['and', ['xxx' => 0, 'yyy' => 2], ['>', 'zzz', $time]);

更多参考 http://www.getyii.com/topic/47

【热门文章】
【热门文章】