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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor