1 //查询条件中如果有中文 2 $keyword= urldecode(I("request.keyword")); 3 if ($keyword!=""){ 4 $Model = new \Think\Model(); 5 6 //SQL查询条件 7 $condition['name'] = array('like',"%".$keyword."%"); 8 $condition['nickname'] = array('like',"%".$keyword."%"); 9 $condition['telephone'] = array('like',"%".$keyword."%"); 10 $condition['_logic'] = 'OR'; 11 12 $count = $Model->table('userinfo')->where($condition)->count(); 13 $Page = new \Think\Page($count,10); 14 15 //查询条件带入参数 16 $map['keyword'] = $keyword; 17 foreach($map as $key=>$val) { 18 $Page->parameter[$key]=urlencode($val); 19 } 20 $show = $Page->show();// 分页显示输出 21 $list=$Model->table('userinfo')->where($condition)->limit($Page->firstRow.','.$Page->listRows)->select(); 22 23 $this->assign('page',$show);// 赋值分页输出 24 $this->assign('list',$list); 25 } 26 $this->display();