有一个查询我想在 Yii2 中转换成 ActiveQuery 模型:查询:SELECT * FROM commodity where ( code like "1122%" or code like "1111%" ) and
( subid = 19 or subid = 323 ) order by name asc有型号:class Commodity extends ActiveRecord{
...}我想要实现的格式,例如:Commodity::find()->where()->andWhere()->all();
1 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
你可以这样做:
$models = Commodity::find() ->where(['or like', 'code', ['1122%', '1111%'], false]) ->andWhere(['subid' => [19, 323]]) ->orderBy(['name' => SORT_ASC]) ->all();
- 1 回答
- 0 关注
- 79 浏览
添加回答
举报
0/150
提交
取消