PHP
发布时间:2019-11-12 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了YII框架中搜索分页jQuery写法详解,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
控制层
request->get(
);
//实例化query
$query=new Query(
);
$query->from('
stud_user'
);
//判断
if(isset($where['sex'])&&$where['sex']
!='')
{
//判断
if($where['sex']=='男')
{
$query->andWhere(['
stud_sex'=>0]
);
}
if($where['sex']=='女')
{
$query->andWhere(['
stud_sex'=>1]
);
}
}else
{
$where['sex']='';
}
//年龄
if(isset($where['age'])&&$where['age']
!='')
{
$query->andWhere(['>','
stud_age',$where['age']]
);
}else
{
$where['age']='';
}
//分页
$pagination = new Pagination(['@R_57_1
0586@lCount' => $query->count()]
);
//条数
$pagination->setPageSize('3'
);
//条件
$query->offset($pagination->offset)->limit($pagination->limit
);
//执行
$userInfo=$query->all(
);
//print_r($userInfo
);die;
return $this->render('search',['userInfo'=>$userInfo,'page'=>$pagination,'where'=>$where]
);
}
模型层
php
namespace frontend\models;
use Yii;
use yii\db\ActiveRecord;
class
studUser extends ActiveRecord
{
/
**
* 声明表名
*
*/
public static function tabl
ename()
{
return '
{{%
stud_user}}';
}
/
**
* 验证规则
*
*/
public function rules()
{
return [
['
stud_age','
Integer'],];
}
}
视图层
Url::toRoute(['admin/search']),'method'=>'get',]
);
echo '性别'," ",Html::input('text','sex',$where['sex']
);
echo '年龄','age',$where['age']
);
echo Html::submitButton('提交'
);
ActiveForm::end(
);
?>
$page,'nextPageLabel'=>'下一页'
]
);?>
分页的样式在
LinkPager.php中
以上所述是小编给大家介绍的YII框架中搜索分页jQuery写法详解。菜鸟教程 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得菜鸟教程不错,可分享给好友!感谢支持。
大佬总结
以上是大佬教程为你收集整理的YII框架中搜索分页jQuery写法详解全部内容,希望文章能够帮你解决YII框架中搜索分页jQuery写法详解所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。