Authored by whb

修改bug

... ... @@ -203,11 +203,14 @@ EOT;
if($this->_platform == 'android' || $this->_platform == 'iphone')
{
$exceptTags = array('视频');
$news[] = Facade_News::getSameNewsById($id, $exceptTags);
$temp = Facade_News::getList(array(), 0, 5, $exceptTags);
unset($temp[$id]);
$news = array_merge($news, $temp);
$news = array_slice(array_filter($news), 0, 3);
$temp = Facade_News::getSameNewsById($id, $exceptTags);
$temp2 = Facade_News::getLatestNews(array(), 0, 5, $exceptTags);
unset($temp2[$id]);
if(!empty($temp))
{
$news = array($temp['id'] => $temp);
}
$news = array_slice(array_filter($news + $temp2), 0, 3);
}
$info['title'] = strip_tags($info['title']);
$info['pics'] = array_filter(explode('|', $info['pics']));
... ... @@ -231,11 +234,14 @@ EOT;
$tag = '视频';
$exceptTags = array('手机视频');
$recom = array();
$recom[] = Facade_News::getSameNewsById($id, $exceptTags);
$temp = Facade_News::getList(array(), 0, 5, $exceptTags);
unset($temp[$id]);
$recom = array_merge($recom, $temp);
$recom = array_slice(array_filter($recom), 0, 3);
$temp = Facade_News::getSameNewsById($id, $exceptTags);
$temp2 = Facade_News::getLatestNews(array(), 0, 5, $exceptTags);
unset($temp2[$id]);
if(!empty($temp))
{
$recom = array($temp['id'] => $temp);
}
$recom = array_slice(array_filter($recom + $temp2), 0, 3);
$hotVideo = array_values(Facade_News::getListByDateHits($tag, 0, 5, $exceptTags));
$lastVideo = array_values(Facade_News::getLatestNews($tag, 0, 5, $exceptTags));
$list['recom'] = $recom;
... ...
... ... @@ -273,7 +273,7 @@ class Facade_News
$news = array();
if(!empty($ids))
{
$news = self::service()->getNewsByOrderId($ids, $exceptTags);
$news = self::service()->getNewsByIds($ids, $exceptTags);
}
return $news;
}
... ...
... ... @@ -256,7 +256,7 @@ class Service_News extends Lib_Service
* @param array $exceptTags
* @return int
*/
public function getNewsByOrderId($ids, $exceptTags)
public function getNewsByIds($ids, $exceptTags)
{
$exceptWhere = "1";
if(is_numeric($ids))
... ... @@ -269,7 +269,7 @@ class Service_News extends Lib_Service
$exceptTags = implode("','", $exceptTags);
$exceptWhere = " `tag` NOT IN ('$exceptTags') ";
}
return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getNewsByOrderId', array('order_ids' => $ids),
return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getNewsByIds', array(),
array('where'=> $exceptWhere, 'ids'=> $ids));
}
... ... @@ -284,7 +284,8 @@ class Service_News extends Lib_Service
*/
public static function getLatestNews($tag, $offset, $limit, $exceptTags = array())
{
$exceptWhere = "1";
$exceptWhere = '1';
$where = '1';
if(is_array($exceptTags) && !empty($exceptTags))
{
$exceptTags = implode("','", $exceptTags);
... ...
... ... @@ -45,8 +45,8 @@
<select id="getListByHits">
SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY hits DESC LIMIT :offset, :limit
</select>
<select id="getNewsByOrderId">
SELECT * FROM tbl_news WHERE #where# AND id IN (#ids#) ORDER BY FIND_IN_SET(id, :order_ids)
<select id="getNewsByIds">
SELECT * FROM tbl_news WHERE #where# AND id IN (#ids#) ORDER BY create_time DESC
</select>
<select id="getLatestNews">
SELECT * FROM `tbl_news` #where# order by create_time DESC LIMIT :offset, :limit
... ...