Home  >  Article  >  Backend Development  >  ThinkPHP有变量的where条件分页实例_PHP

ThinkPHP有变量的where条件分页实例_PHP

WBOY
WBOYOriginal
2016-05-31 19:28:39710browse

ThinkPHP

本文实例讲述了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程序设计有所帮助。

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