Yii2 model中的多个where 我如何放进去?



 $goods_filter['goods_id']   = $goods_id;
        $goods_filter['status']     = 'true';
        $goods_filter['from_time']  = ['<','from_time',$time];
        $goods_filter['to_time']    = ['>','to_time',$time];

        print_r($goods_filter);die;
    //这个where 条件 如何写呢??
        $goods_promotion = $obj_goods->getList('*',$goods_filter,0,10);

    /**
     * 
     * @param  string $field   [description]
     * @param  array  $filter  [description]
     * @param  string $offset  [description]
     * @param  string $limit   [description]
     * @param  string $orderBy [description]
     * @return [type]          [description]
     */
    public function getList($field='*',$filter=[],$offset='0',$limit='10',$orderBy='',$andWhere=[])
      {    

          return Goods::find()->select($field)->where($filter)->offset($offset)->limit($limit)->orderBy($orderBy)->asArray()->all();

      }

yii2

我是节操帝 9 years, 2 months ago

YII2查询构建器

楼主可以看看

牧濑红莉栖 answered 9 years, 2 months ago

后两个不用指定 key

ratchen answered 9 years, 2 months ago

Your Answer