public static function handle($select, $sql, $rsnum) { if (empty(self::$num)) { self::$num = CORE::$cfg["item_num"]; } if (!empty($rsnum) && $rsnum > self::$num) { $offset = 0; list($offset, $oldNum) = explode(',', $select['limit']); self::$all = ceil($rsnum / self::$num); # 總頁數 if (empty(self::$now)) { self::$now = 1; } if (self::$now < 0 || self::$now > self::$all) { self::$now = 1; } self::$start = $limit_start = self::$num * self::$now - self::$num + $offset; # limit 開始資料列數 $new_limit = $limit_start . "," . self::$num; # limit 組合完成 $select['limit'] = $new_limit; $sql_page = DB::select($select); $page = array($sql_page, DB::num($sql_page)); self::row(); } else { self::$now = 1; $page = array($sql, $rsnum); } SESS::write('PAGE', self::$now); return $page; }
private static function page_handle(array $uri_array) { $origin_args = $uri_array; $last_args = array_pop($uri_array); if (preg_match('/page-/', $last_args)) { PAGE::$now = preg_replace('/page-([0-9]+)/', "\$1", $last_args); # 載入頁次參數 $return_args = $uri_array; } else { $return_args = $origin_args; } self::$uri = implode("/", $return_args); return $return_args; }