Heim  >  Artikel  >  php教程  >  ThinkPHP有变量的where条件分页实例

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

WBOY
WBOYOriginal
2016-06-06 20:18:001395Durchsuche

这篇文章主要介绍了ThinkPHP有变量的where条件分页方法,实例讲述了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程序设计有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn