如何在Yii ActiveRecord中创建IS NOT NULL where子句?

时间:2015-10-25 20:25:28

标签: php activerecord yii2

我尝试了以下

$kw = Keyword::find()->leftJoin('ad_group_keyword', 'keyword_id = keyword.id')->where(['keyword_id' => null, ['not', ['revenue' => null]]])->all();

但它给了我一个错误

  

PHP警告 - yii \ base \ ErrorException   strtoupper()期望参数1为字符串,给定数组为

screenshot http://ipfs.pics/ipfs/QmcoACjLBmTYL3GZd6qG5GoRopVntCohurqWz3BXhbLzTZ

1 个答案:

答案 0 :(得分:2)

使用andWhere

进行更改
$kw = Keyword::find()
             ->leftJoin('ad_group_keyword', 'keyword_id = keyword.id')
             ->where(['keyword_id' => null])
             ->andWhere(['not', ['revenue' => null]])
             ->all();