thinkphp5项目--个人博客(八)
thinkphp5项目--个人博客(八)
项目地址
fry404006308/personalBlog: personalBlog
https://github.com/fry404006308/personalBlog
一、搜索功能

控制器
<?php
namespace app\index\controller; use app\index\controller\Base;
class Search extends Base
{
public function index()
{
$keywords=input('keywords');
if($keywords){
//按照标题搜索
$map['title']=['like','%'.$keywords.'%'];
$searchres=db('article')->where($map)->order('id desc')->paginate($listRows=3,$simple=false,$config=['query'=>array('keywords'=>$keywords)]);
$this->assign(array(
'searchres'=>$searchres,
'keywords'=>$keywords,
));
}else{
$this->assign(array(
'searchres'=>null,
'keywords'=>'暂无数据',
));
}
return view();
}
}
按照文章标题搜索
//按照标题搜索
$map['title']=['like','%'.$keywords.'%'];
$searchres=db('article')->where($map)->order('id desc')->paginate($listRows=3,$simple=false,$config=['query'=>array('keywords'=>$keywords)]);
视图用的是cate控制器的,把它的复制了一份拿过来用,改了点小位置
二、分页传递参数
thinkphp教程
分页参数
主要的分页参数如下: 参数描述
list_rows 每页数量
page 当前页
path url路径
query url额外参数
fragment url锚点
var_page 分页变量
type 分页类名
项目中实例
//按照标题搜索
$map['title']=['like','%'.$keywords.'%'];
$searchres=db('article')->where($map)->order('id desc')->paginate($listRows=3,$simple=false,$config=['query'=>array('keywords'=>$keywords)]);
视图
{$searchres->render()}
不同分页传来的数据不同,前面部分是变化的
thinkphp5项目--个人博客(八)的更多相关文章
- thinkphp5项目--个人博客(五)
thinkphp5项目--个人博客(五) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(七)
thinkphp5项目--个人博客(七) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(六)
thinkphp5项目--个人博客(六) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(四)
thinkphp5项目--个人博客(四) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(三)
thinkphp5项目--个人博客(三) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(一)
thinkphp5项目--个人博客(一) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- thinkphp5项目--个人博客(二)
thinkphp5项目--个人博客(二) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- 2015-2016-2 《Java程序设计》项目小组博客
2015-2016-2 <Java程序设计>项目小组博客 1451 完+美 java项目 守望先疯 JavaGroup 07_10_20_22 FromBottomToTop L.G.Su ...
- 团队项目系列博客 —— 在路上(之wampserver 修改根目录以及配置多站点以及修改端口号)
团队项目系列博客 -- 在路上(之wampserver 修改根目录以及配置多站点以及修改端口号) 标签(空格分隔): wampserver php 参考:参考文献1.慕课网.知乎.github 一.w ...
随机推荐
- ASP.NET-权限管理五张表
ASP.NET 权限管理五张表 权限管理的表(5张表) 每个表里面必有的一些信息 序号 名称 字段 类型 主键 默认值 是否为空 备注 1 用户ID ID INT 是 ...
- 洛谷——P2483 [SDOI2010]魔法猪学院
https://www.luogu.org/problem/show?pid=2483 题目描述 iPig在假期来到了传说中的魔法猪学院,开始为期两个月的魔法猪训练.经过了一周理论知识和一周基本魔法的 ...
- Java并发编程(七)ConcurrentLinkedQueue的实现原理和源码分析
相关文章 Java并发编程(一)线程定义.状态和属性 Java并发编程(二)同步 Java并发编程(三)volatile域 Java并发编程(四)Java内存模型 Java并发编程(五)Concurr ...
- LeetCode104_MaximumDepthofBinaryTree Java题解
题目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the ...
- nyoj--236--心急的C小加(动态规划&&LIS)
心急的C小加 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 C小加有一些木棒,它们的长度和质量都已经知道,需要一个机器处理这些木棒,机器开启的时候需要耗费一个单位的时间 ...
- Oracle 11g AWR生成报告
1.生成单实例 AWR 报告: @$ORACLE_HOME/rdbms/admin/awrrpt.sql 2.生成 Oracle RAC AWR 报告: @$ORACLE_HOME/rdbms/adm ...
- (转)js document.all的用法
document.all用法 一. document.all是页面内所有元素的一个集合.例如: document.all(0)表示页面内第一个元素 二.document.all可以判断浏览器 ...
- (转载)Android学习之Intent使用
ndroid学习之Intent使用 1.使用显示Intent Intent intent = new Intent(FirstActivity.this,SecondActivity.class) ...
- 51nod 1445 变色DNA ( Bellman-Ford算法求单源最短路径)
1445 变色DNA 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有一只特别的狼,它在每个夜晚会进行变色,研究发现它可以变成N种颜色之一,将这些颜色标号为0,1 ...
- BootStrap学习(一)——BootStrap入门
1.环境搭建 中文官网下载地址:http://www.bootcss.com/ 右击选中的WEB项目,点击导入,选择文件系统,然后下一步,选择BootStrap文件目录路径,如下: 完成后,WEB项目 ...