search
Homephp教程php手册集成tp分页类代码

集成tp分页类代码。小伙伴再也不用重复引用了
<?php <br />     class PageExtendsAction extends Action{<br>             /**<br>         @$sqlName 数据表名称 string<br>         @$sql 1:有where条件 2:无where条件 int<br>         @$sqlCon where 条件 string<br>         @$orderField 排序 string<br>         @$pageNum 数量 string<br>         @$DataName 数据输出名称 string<br>         @$DataPage 分页输出名称 string<br>         @$orderIf 多表查询 array<br>         |------array[$i]['field'] 字段名<br>         |------array[$i]['for'] 条件字段<br>         |------array[$i]['sqlName'] 查询表明<br>         |------array[$i]['forField'] 查询后字段<br>         |------array[$i]['getArr'] 是否获取整个数据还是数组元素 1为获取整个数组,2为只获取单个元素<br>         */<br>         public function DataPage($sqlName,$sql,$sqlCon,$pageNum,$orderField,$DataName,$DataPage,$orderIf){<br>             $Data = M($sqlName); // 实例化Data数据对象<br>             import('ORG.Util.Page');// 导入分页类<br>             if($sql == 1){<br>                 $count = $Data->where($sqlCon)->count();// 查询满足要求的总记录数 $map表示查询条件<br>             }else if($sql == 2){<br>                 $count = $Data->count();// 查询满足要求的总记录数 $map表示查询条件<br>             }<br>             $Page = new Page($count,$pageNum);// 实例化分页类 传入总记录数<br>             $show = $Page->show();// 分页显示输出<br>             if($sql == 1){<br>                 $list = $Data->where($sqlCon)->order($orderField)->limit($Page->firstRow.','.$Page->listRows)->select();// 进行分页数据查询<br>             }else if($sql == 2){<br>                 $list = $Data->order($orderField)->limit($Page->firstRow.','.$Page->listRows)->select();// 进行分页数据查询<br>             }<br>             // -------------------------------------<br>             // ---------@多表调用名称@ start---------<br>             if($orderIf != null){<br>                 for($i=0;$i<count></count>                     for($j=0;$j<count></count>                         // 参数分解<br>                         $field = $orderIf[$j]['field'];<br>                         $for = $orderIf[$j]['for'];<br>                         $sqlName = $orderIf[$j]['sqlName'];<br>                         $forField = $orderIf[$j]['forField'];<br>                         // 赋值操作<br>                         $id = $list[$i][$field];<br>                         $arr = M($sqlName) -> where("$for = $id") -> find();<br>                         if($orderIf[$j]['getArr'] == 1){<br>                             $list[$i][$field] = $arr;<br>                         }else if($orderIf[$j]['getArr'] == 2){<br>                             $list[$i][$field] = $arr[$forField];<br>                         }else{<br>                             echo "非法操作";<br>                         }<br>                     }<br>                 }<br>             }<br>             // -------------------------------------<br>             // ---------@多表调用名称@ end---------<br>             $this->assign($DataName,$list);// 赋值数据集<br>             $this->assign($DataPage,$show);// 赋值分页输出<br>         }<br>     }<br> ?>

AD:真正免费,域名+虚机+企业邮箱=0元

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.