1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| function get_cat_articles($cat_id, $page = 1, $size = 20 ,$requirement='') { if ($cat_id == '-1') { $cat_str = 'cat_id > 0'; } else { $cat_str = get_article_children($cat_id); } if ($requirement != '') { $sql = 'SELECT article_id, title, content, author, add_time, file_url, open_type' . ' FROM ' .$GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC'; } else { $sql = 'SELECT article_id, title, content, author, add_time, file_url, open_type' . ' FROM ' .$GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC'; }
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page-1) * $size);
$arr = array(); if ($res) { while ($row = $GLOBALS['db']->fetchRow($res)) { $article_id = $row['article_id'];
$arr[$article_id]['id'] = $article_id; $arr[$article_id]['title'] = $row['title']; $arr[$article_id]['content'] = $row['content']; $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author']; $arr[$article_id]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid'=>$article_id), $row['title']) : trim($row['file_url']); $arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']); } }
return $arr; }
|