wxd

wxd

这家伙有点懒,还没写个性签名!

  • 财富值45
  • 威望值10
  • 总积分155

个人信息

  • 回答了问题 yii2 AR搜索分页

    文件上传 多文件

    `控制器
     yii\web\UploadedFile;
     $model->file = UploadedFile::getInstances($model, 'file');
            $file_arr = array();
            foreach($model -> file as $file){
                $file_name = 'uploads/' . time() . rand(111111,999999).'.'. $file->extension;
                $file -> saveAs($file_name);
                $file_arr[] = $file_name;
            }
     视图:
    <?php
     use yii\widgets\ActiveForm;
     use yii\helpers\Html;
    ?>
     <?php $form=ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data'],'action'=>   ['news/upfile'],'method'=>'post',])?>
     <?=$form->field($model,'file[]')->fileInput(['multiple'=>true])?>
     <?php echo Html::submitButton('提交',['class' => 'btn btn-primary'])?>
    <?php ActiveForm::end();?>
    

    `

  • 赞了回答
            ```
     首先引入
               yii\data\Pagination;
               还有各种模型
            控制器:
                new一个AR对象出来
                $search = Yii::$app->request->get('search_key');
                $where = '1 = 1';
                    if ($search) {
                        $where .= ' and JName like "%'.$search.'%"';
                    }
                    $pageArr = $model -> find()->where($where);
                    $pagination = new Pagination(['totalCount' => $pageArr -> count(),'pageSize'=>'3']);
                    $result = $pageArr ->join('INNER JOIN', 'recruit_enterprise','recruit_enterprise.CId = recruit_job.CId')
                                       ->select('*')
                                       ->offset($pagination ->offset)
                                       ->limit($pagination ->limit)
                                       ->where($where)
                                       ->asArray()
                                       ->all();
    
                    return $this -> render('job_list',
                        ['result' => $result,
                        'pagination' => $pagination,
                        ]
                    );
    
    
    
          以上是本人个人代码    仅供参考
    
  • 收藏了问题
    yii2 AR搜索分页
  • 回答了问题 yii2 AR搜索分页
            ```
     首先引入
               yii\data\Pagination;
               还有各种模型
            控制器:
                new一个AR对象出来
                $search = Yii::$app->request->get('search_key');
                $where = '1 = 1';
                    if ($search) {
                        $where .= ' and JName like "%'.$search.'%"';
                    }
                    $pageArr = $model -> find()->where($where);
                    $pagination = new Pagination(['totalCount' => $pageArr -> count(),'pageSize'=>'3']);
                    $result = $pageArr ->join('INNER JOIN', 'recruit_enterprise','recruit_enterprise.CId = recruit_job.CId')
                                       ->select('*')
                                       ->offset($pagination ->offset)
                                       ->limit($pagination ->limit)
                                       ->where($where)
                                       ->asArray()
                                       ->all();
    
                    return $this -> render('job_list',
                        ['result' => $result,
                        'pagination' => $pagination,
                        ]
                    );
    
    
    
          以上是本人个人代码    仅供参考
    
  • 关注了
  • 2017-08-24 已签到
    连续签到1天,获得了5个金钱
助理 等级规则
155/200
资料完整度
10/100
用户活跃度
0/100

Ta的关注

7

Ta的粉丝

5

Ta的访客

7