ThinkPHP有变量的where条件分页实例,thinkphpwhere
本文实例讲述了ThinkPHP有变量的where条件分页的实现方法。分享给大家供大家参考。
主要功能代码如下:
复制代码 代码如下:
$Form= D('Announcement');
import("ORG.Util.Page");
$count = $Form->count(); //计算总数
$p = new Page ( $count, 5 );
$map = array();// 使用索引数组或者对象来作为查询条件,使用对象方式和使用数组方式的条件效果是相同的,并且是可以互换的。
$map['user_id']=$_SESSION['loginUserId']; //
$list=$Form->limit($p->firstRow.','.$p->listRows)->order('announcement_id desc')->where($map)->findAll(); //分页语句写法 where直接运用
//dump($Form->getLastSql()); //打印出sql语句
$page = $p->show (); //分页映射
希望本文所述对大家的PHP程序设计有所帮助。
public function index() {//把图标改一下样式就可以了 $user = M('User'); import('ORG.Util.Page'); $count = $user->count(); $listRows = 5; $page = new Page($count, $listRows); $list = $user->limit("{$page->firstRow},{$page->listRows}")->select(); $page->setConfig('prev', '');//上一页 $page->setConfig('next', '
');//下一页 // $page->setConfig('first', ''); // $page->setConfig('last', ''); $page->setConfig('theme', '%upPage% %downPage%');//只显示上下页选项 $this->assign('page', $page->show()); $this->assign('list', $list); $this->display();}
你在tp的手册上直接复制 那段代码 就不会出错

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools
