/** * 文章列表 * @param int $cid 分类 * @param int $limit limit * @param string $sidetable 是否查询附表 * @param int $cache 缓存时间 * @return array */ public static function SIMPLEARTICLES($cid, $limit, $sidetable = 0, $cache = 3600) { $contentdata = self::QCREADCACHE('SIMPLEARTICLES_' . $cid); if (!$contentdata) { $Category = DD('Category'); $cateinfo = $Category->findbyid($cid); $model = DD('Model'); $modelinfo = $model->findByID($cateinfo['mid']); $content = DD('Content', array($modelinfo['table'])); $contentinfo = $content->SimpleLimit($cid, $limit); $contentdata = array(); $newcontentinfo = array(); $ids = ''; foreach ($contentinfo as $k => $c) { $ids .= $c['id'] . ','; $newcontentinfo[$c['id']] = $c; $newcontentinfo[$c['id']]['href'] = Route::CUrl('Content/Content/news', array('id' => $c['id'], 'cid' => $cid)); } if ($sidetable == 1) { //查询副表 $contentdata = DD('ContentData', $modelinfo['table']); $contentdatainfo = $contentdata->selByIds($ids); foreach ($contentdatainfo as $c => $d) { $contentdata[] = array_merge($newcontentinfo[$d['aid']], $d); } } else { $contentdata = $newcontentinfo; } self::QCWRITECACHE('SIMPLEARTICLES_' . $cid, $contentdata, $cache); } return $contentdata; }