ThinkPHP where conditional paging instance with variables
- 2021-07-24 10:23:24
- OfStack
This paper describes the implementation method of where conditional paging with ThinkPHP variables. Share it for your reference.
The main function codes are as follows:
$Form= D('Announcement');
import("ORG.Util.Page");
$count = $Form->count(); // Calculate the total
$p = new Page ( $count, 5 );
$map = array();// Use indexed arrays or objects as query conditions , The conditional effects of using object mode and array mode are the same and interchangeable.
$map['user_id']=$_SESSION['loginUserId']; //
$list=$Form->limit($p->firstRow.','.$p->listRows)->order('announcement_id desc')->where($map)->findAll(); // Writing of paging statement where Direct application
//dump($Form->getLastSql()); // Print out sql Statement
$page = $p->show (); // Paging mapping
I hope this article is helpful to everyone's PHP programming.