ecmall分页
在Ecmall的二次开发中,分页是必不可少的。这个系统已经自带了分页功能,下面来看看如何使用这个分页。
下面是一个自定义的类,用于查看订单的详细情况。关键在于get_order_data()这个方法,分页的使用也在这个方法的内部了。应该有的注释都有了,应该会比较容易懂,我不就多说了。
<?php
define('NUM_PER_PAGE', 15); // 每页显示数量 class NowaMagicApp extends MallbaseApp
{
public function index()
{
/* 分页信息 */
$page = $this->_get_page(NUM_PER_PAGE);
$page['item_count'] = $stats['total_count'];
$this->_format_page($page);
$this->assign('page_info', $page); $this->display('gorder.index.html');
} /* 订单记录 */
function orderslog()
{
$goods_id = empty($_GET['id']) ? 0 : intval($_GET['id']);
if (!$goods_id)
{
$this->show_warning('Hacking Attempt');
return;
} $data = $this -> get_order_data($goods_id); if ($data === false)
{
return;
} $this->assign('order', $data); $this->display('gorder.index.html'); } function get_order_data($goods_id)
{
//clean_cache();
$cache_server =& cache_server();
//print_r($cache_server);
$key = 'order_' . $goods_id;
//$key = $this->_get_cache_id();
$r = $cache_server->get($key);
$cached = true; $db = &db(); $sql = "select count(*)
from shop_order a, shop_order_extm b, shop_order_goods c
where a.order_id = b.order_id and b.order_id = c.order_id
and c.goods_id = '".$goods_id."'
and a.status != '11'
and a.status != '0'
and a.status != '20'
order by a.add_time desc ";
//echo $sql;
$num = $db -> getone($sql); //求出总记录数
$page = $this->_get_page(NUM_PER_PAGE); //每页显示的条数,默认是10条
$page['item_count'] = $num; // 返回一个数组$page,$page['limit']=0,10
$this->_format_page($page); //格式化分页 $sql2 = "select a.order_id, a.buyer_name, a.add_time, a.status, b.phone_tel, b.phone_mob, b.consignee, c.price, c.quantity, c.goods_id
from shop_order a, shop_order_extm b, shop_order_goods c
where a.order_id = b.order_id and b.order_id = c.order_id
and c.goods_id = '".$goods_id."'
and a.status != '11'
and a.status != '0'
and a.status != '20'
order by a.add_time desc limit ".$page['limit']; $result = $db -> query($sql2); $this -> assign('page_info',$page); //向模板页传递页数
$this -> assign('que',$sql2); //向模板页传递查询结果 //$r = array();
while($myrow = $db -> fetch_array($result))
{
$r[] = $myrow;
} $cache_server->set($key, $r, 1);
return $r;
} } ?>
简化如下:
Define("LIMIT",10);
$goods_mod = & db('test');//构建实体模型(操作表)
$count = 'select count(id) from test';
$num = $goods_mod -> getone($count);//求出总记录数
$page = $this->_get_page(LIMIT);//每页显示的条数,默认是10条
$page['item_count'] = $num;// 返回一个数组$page,$page['limit']=0,10
$this->_format_page($page);//格式化分页
$sql = 'select id,title,content from test order by id desc limit '.$page['limit'];
$que = $goods_mod -> getAll($sql);//查询记录
$this -> assign('page_info',$page); //向模板页传递页数
$this -> assign('que',$que); //向模板页传递查询结果
ecmall分页的更多相关文章
- Ecmall系统自带的分页功能
在Ecmall的二次开发中,分页是必不可少的.这个系统已经自带了分页功能,下面来看看如何使用这个分页. 下面是一个自定义的类,用于查看订单的详细情况.关键在于get_order_data()这个方法, ...
- ecmall中的分页问题
<ecmall>Ecmall系统自带的分页功能 在Ecmall的二次开发中,分页是必不可少的.这个系统已经自带了分页功能,下面来看看如何使用这个分页. 下面是一个自定义的类,用于查看订单的 ...
- Ecmall系统自带的分页功能使用
在控制器如果没有定义相关模型,直接使用sql语句的话,直接使用如下语句. 即: public $db; $this->db = &db(); //然后开始使用分页类 $sql='sele ...
- 记一次SQLServer的分页优化兼谈谈使用Row_Number()分页存在的问题
最近有项目反应,在服务器CPU使用较高的时候,我们的事件查询页面非常的慢,查询几条记录竟然要4分钟甚至更长,而且在翻第二页的时候也是要这么多的时间,这肯定是不能接受的,也是让现场用SQLServerP ...
- js实现前端分页页码管理
用JS实现前端分页页码管理,可以很美观的区分页码显示(这也是参考大多数网站的分页页码展示),能够有很好的用户体验,这也是有业务需要就写了一下,还是新手,经验不足,欢迎指出批评! 首先先看效果图: 这是 ...
- JdbcTemplate+PageImpl实现多表分页查询
一.基础实体 @MappedSuperclass public abstract class AbsIdEntity implements Serializable { private static ...
- MVC如何使用开源分页插件shenniu.pager.js
最近比较忙,前期忙公司手机端接口项目,各种开发+调试+发布现在几乎上线无问题了:虽然公司项目忙不过在期间抽空做了两件个人觉得有意义的事情,一者使用aspnetcore开发了个人线上项目(要说线上其实只 ...
- NET Core-TagHelper实现分页标签
这里将要和大家分享的是学习总结使用TagHelper实现分页标签,之前分享过一篇使用HtmlHelper扩展了一个分页写法地址可以点击这里http://www.cnblogs.com/wangrudo ...
- 套用JQuery EasyUI列表显示数据、分页、查询
声明,本博客从csdn搬到cnblogs博客园了,以前的csdn不再更新,朋友们可以到这儿来找我的文章,更多的文章会发表,谢谢关注! 有时候闲的无聊,看到extjs那么肥大,真想把自己的项目改了,最近 ...
随机推荐
- MapReduce:汇总学生表和成绩表为----学生成绩表
已知两张数据表,其中表一存储的是学生编号.学生姓名:表二存储的是学生编号.考试科目.考试成绩:编写mapreduce程序,汇总两张表数据为一张统一表格. 表一: A001 zhangsan A002 ...
- [CF489D]Unbearable Controversy of Being
题目大意:求有向图中这种图的数量 从分层图来考虑,这是一个层数为3的图 枚举第一个点能到达的所有点,对他们进行BFS求第三层的点(假装它是BFS其实直接枚举效果一样) 代码: #include< ...
- python部署LNMP业务服务环境
- 探测web服务质量方法
- Eclipse 添加JSP模板
0.环境 Eclipse IDE for Java EE Developers (4.3.2) win8.1系统 1.原因 Eclipse自带新建JSP为: <%@ page language= ...
- Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). Git fet ...
- MarkDown中锚的使用
经常使用Markdown配合Mou编辑器来些点总结和文档,但是其中需要前后引用或链接时markdown木有提供直接的方式.当然,Markdown支持嵌入式HTML语法,so..实现起来也没啥问题. 具 ...
- jsonp跨域传过来的数据格式
var uri1 = 'https://api.github.com?callback=JSON_CALLBACK'; /**/JSON_CALLBACK({ "meta": { ...
- D3.js学习笔记(四)—— 使用SVG坐标空间
目标 在这一章,你将要使用D3.js基于一些数据把SVG元素添加到你想要的坐标位置上. 我们的目标就是使用下面的数据集: var spaceCircles = [30,70,110]; 并使用D3.j ...
- ctci1.1
) ; ; i < len; i++){ if(place.find(str[i]) == place.end()) place. ...