ThinkPHP has variable where conditional paging example, thinkphpwhere
The example in this article describes the implementation method of where conditional paging with variables in ThinkPHP. Share it with everyone for your reference.
The main function codes are as follows:
Copy code The code is as follows:
$Form= D('Announcement');
import("ORG.Util.Page");
$count = $Form->count(); //Calculate the total number
$p = new Page ( $count, 5 );
$map = array();//Use index array or object as query condition. The condition effects of using object mode and array mode are the same and are interchangeable.
$map['user_id']=$_SESSION['loginUserId']; //
$list=$Form->limit($p->firstRow.','.$p->listRows)->order('announcement_id desc')->where($map)->findAll (); //How to write paging statements where directly use
//dump($Form->getLastSql()); //Print out the sql statement
$page = $p->show (); //Paging mapping
I hope this article will be helpful to everyone’s PHP programming design.
public function index() {//Just change the style of the icon $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', '');//Previous page $page->setConfig('next', '');//Next page// $page-> setConfig('first', ''); // $page->setConfig('last', ''); $page->setConfig('theme', '%upPage% %downPage%');// Only display the upper and lower page options $this->assign('page', $page->show()); $this->assign('list', $list); $this->display(); }
You can copy that code directly from the TP manual and there will be no errors
http://www.bkjia.com/PHPjc/904924.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904924.htmlTechArticleThinkPHP where conditional paging with variables example, thinkphpwhere This example describes the implementation method of ThinkPHP where conditional paging with variables . Share it with everyone for your reference. Main functions...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn