YII2 获取post以及查询


if(Yii::$app->request->Post('select'))
{
$data=\Yii::$app->request->post('UserLocationSearch');
//print_r($data);exit();
$reasonable=$data['reasonable'];
$username=$data['username'];
$start_time=!empty($data['start_time'])?strtotime($data['start_time']):DateHelper::getDayStartTime(7);
$end_time=!empty($data['end_time'])?(strtotime($data['end_time'])+86399):DateHelper::getTodayEndTime();
$searchModel = new UserLocationSearch();
$data = $searchModel->search(Yii::$app->request->queryParams);
$data->query->orderBy('time desc');
$data->query->andWhere(['between','time',$start_time,$end_time]);
$data->query->andWhere(['like', 'name', $username]);
if(!empty($reasonable))
{
$data->query->andWhere(['reasonable'=>$reasonable]);
}
$searchModel->reasonable=$reasonable;
$searchModel->username=$username;
$searchModel->start_time=date('Y-m-d',$start_time);
$searchModel->end_time=date('Y-m-d',$end_time);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $data,
]);

}

声明:祁志飞||小祁的博客|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - YII2 获取post以及查询


QQ:137867590