📄 正在查看:twcms/model/cms_content_tag_data_model.class.php
1<?php
2/**
3 * (C)2012-2014 twcms.com TongWang Inc.
4 * Author: wuzhaohuan <kongphp@gmail.com>
5 */
6
7defined('TWCMS_PATH') or exit;
8
9class cms_content_tag_data extends model {
10 function __construct() {
11 $this->table = ''; // 表名 (可以是 cms_article_tag_data cms_product_tag_data cms_photo_tag_data 等)
12 $this->pri = array('tagid', 'id'); // 主键
13 }
14
15 // 获取标签列表
16 public function list_arr($tagid, $orderway, $start, $limit, $total) {
17 // 优化大数据量翻页
18 if($start > 1000 && $total > 2000 && $start > $total/2) {
19 $orderway = -$orderway;
20 $newstart = $total-$start-$limit;
21 if($newstart < 0) {
22 $limit += $newstart;
23 $newstart = 0;
24 }
25 $list_arr = $this->find_fetch(array('tagid' => $tagid), array('id' => $orderway), $newstart, $limit);
26 return array_reverse($list_arr, TRUE);
27 }else{
28 return $this->find_fetch(array('tagid' => $tagid), array('id' => $orderway), $start, $limit);
29 }
30 }
31}
32