Exemplo n.º 1
0
 private function pagingDemo()
 {
     $data = array();
     for ($i = 0; $i < 100; $i++) {
         $data[$i]['id'] = $i;
         $data[$i]['name'] = 'Test' . $i;
     }
     /*
      * 分页类使用说明:
      * 
      * 参数1:具体用法见本方法前面的“特别说明”
      * 参数2:每页包含的数据项个数
      * 参数3:页码数,空则表示首页
      * 参数4:分页模式,目前支持的 Mode 有三种,分别是 Google、Common、JavaEye 的分页模式
      * 
      * 更多使用方法请参考 hush-lib/Hush/Paging.php 类中的使用说明
      */
     $page = new Ihush_Paging($data, 5, null, array('Href' => '/test/p/{page}?debug=time', 'Mode' => 3));
     /*
      * 打印数组形式:
      * 
      * 此数组可以提供给 Smarty 等模板直接展示,非常方便!
      * 其中较常被展示的就是 totalPage(总页数)、prevStr(上页字串)、nextStr(下页字串)、pageStr(分页字串)
      */
     Hush_Util::dump($page->toArray());
 }
Exemplo n.º 2
0
 /**
  * used by RequestPage::sendListAction
  */
 public function getSendByPage($uid)
 {
     $eachPageNum = 10;
     $condition = $this->select()->join($this->t3, "{$this->t1}.{$this->k3} = {$this->t3}.{$this->k3}", null)->join($this->t4, "{$this->t1}.{$this->k4} = {$this->t4}.{$this->k4}", null)->where("{$this->t1}.author_id = ?", $uid)->order("{$this->t1}.{$this->k1} desc");
     $condition2 = clone $condition;
     // used to buid $sql_list
     $sql_count = $condition->from($this->t1, array("count(1) as total"));
     $sql_list = $condition2->from($this->t1, array("{$this->t1}.*", "{$this->t3}.bpm_node_name", "{$this->t4}.bpm_flow_name"))->limitPage(Hush_Util::param('p'), $eachPageNum);
     $total = $this->dbr()->fetchOne($sql_count);
     $pager = new Ihush_Paging($total, $eachPageNum, null, array('Href' => '/request/sendList/p/{page}', 'Mode' => 2));
     return array('list' => $this->dbr()->fetchAll($sql_list), 'page' => $pager->toArray());
 }