AR查询的时候,where条件不为空怎么写 [ 2.0 版本 ]
官方的文档中有一个为空的例子:
// ...WHERE (`status` = 10) AND (`type` IS NULL) AND (`id` IN (4, 8, 15))
$query->where([
'status' => 10,
'type' => null,
'id' => [4, 8, 15],
]);
那不为空的条件怎么写呢?
最佳答案
-
chocoboxxf 发布于 2015-11-18 18:09 举报
$query ->where(['status' => 10]) ->andWhere(['NOT', ['type' => null]]) ->andWhere(['id' => [4, 8, 15]])
共 3 条回复supperAlien 回复于 2016-12-12 11:36 回复@╃巡洋艦㊣ 为什么在
andFilterWhere
之后却需要是->andFilterWhere(['NOT', ['type' => 'null']])
null必须加引号luoxiao 觉得很赞
其他 0 个回答
没有找到数据。
ArronYR
注册时间:2015-03-09
最后登录:2016-10-11
在线时长:3小时19分
最后登录:2016-10-11
在线时长:3小时19分
- 粉丝0
- 金钱20
- 威望0
- 积分50