您现在的位置是:首页 > PHP技术PHP技术
Thinkphp5.1.30查询和查询分页代码
2018-12-10【PHP技术】1724 人已围观
简介查询是非常频繁使用的功能。thinkphp5.1.30查询功能一般流程如下$keywords=Request::param(...
查询是非常频繁使用的功能。thinkphp5.1.30查询功能一般流程如下
$keywords = Request::param('keywords'); //申明变量 $whr = []; $whr[] = ['del_flag','=',0]; //给出一个固定通用条件 if($keywords <>""){ $whr[] = ['title','like','%'.$keywords.'%']; } $list = Db::name('ads) ->where($whr) ->paginate(5,false,[ 'query'=>Request:param(), ]) $this->assign('list',$list); return $this->fetch();
重点tp5.1.30中like查询使用数组拼接
$whr[] = [字段名,'like',关键字]
分页重点传递参数
paginate(页显示数,简单查询false,附带参数
[
'query'=>省事就全部参数Request::param()
]
)
关注宁波网站建设博客,更多精彩分享,敬请期待!
Tags:
很赞哦! ()
相关文章
随机图文
thinkphp imagettftext(): Could not find/open font验证码无法显示报错
thinkphp imagettftext(): Could not find/open font tp5.1验证码无法显示.打开debu...Sublime Text添加插入带当前代码段说明
sublime是小编目前使用当中的一款php程序编辑器,功能非常的强大,今天推荐给各位.下面是如何在代码段内快捷插入常用说明.非常实用哦 ...在HTML中引入css的其中的两个方法
1在HTML中引入css的其中的两个方法1.1 使用链接式link href="style.css" rel="...网站安全代码thinkphp3.1密码强度检测
/** *检查密码复杂度 */ publicfunctioncheckPassword($pwd){ if($pwd==null){...