2017-06-09 11 views
0

私が持っている機能:エラー:PHPパブリック関数での文書の最後に余分なコンテンツ

protected function getFeedCategory($lng) { 
    $params = $this->dispatcher->getParam('format', null, '/id/1'); 
    $pArr = explode("/", $params); 
    $limit = 10; 
    //varDump($pArr); 
    //varDump($this->dispatcher->getParams()); 
    try { 

     $categoryId = (isset($pArr[2])) ? (int)$pArr[2] : 1; 
     $cache_key = 'Frontend_Feed_getFeedCategory_' . $categoryId . '_limit_' . $limit . '_' . $lng; 
     //$this->_cache->delete($cache_key); 
     if (($items = $this->_cache->get($cache_key)) == null || $this->cache_renew_data->can_refrash) { 
      $items = $this->db->fetchAll("SELECT n.date_show, n.title_{$lng} AS title,n.id,n.is_ru,n.is_md,n.is_new,n.thumb_md,n.thumb_ru, 
              n.thumb_en 
              FROM news AS n 
              LEFT JOIN news_categories AS nc ON nc.news_id=n.id 
              WHERE n.is_{$lng} = 1 AND n.date_show < '" . date(MYSQL_DATE_FORMAT) . "' 
              AND nc.categories_id = {$categoryId} 
              ORDER BY n.date_show DESC LIMIT 0," . $limit); 
      //varDump($items); 
      if (count($items)) { 
       $this->_cache->save($cache_key, $items); 
      } 
     } 


    } catch (\Exception $e) { 
     return $this->getAll($lng, 20); 
    } 

    return $items; 
} 

そして、この戻り列1の2行目でエラー:最後に余分なコンテンツどのように私はそれを修正することができますか?

case 'feed-category' : $items = $this->getFeedCategory($lng); break;

このコードは、URLでコンテンツを入手します!

答えて

0
public function getFeedCategory($lng) { 
    $params = $this->dispatcher->getParam('format', null, '/id/1'); 
    $pArr = explode("/", $params); 
    $limit = 10; 

    try { 
     $categoryId = (isset($pArr[2])) ? (int)$pArr[2] : 1; 
     $cache_key = 'Frontend_Feed_getFeedCategory_' . $categoryId . '_limit_' . $limit . '_' . $lng; 

     if (($items = $this->_cache->get($cache_key)) == null || $this->cache_renew_data->can_refrash) { 
      $items = $this->db->fetchAll("SELECT n.date_show, n.title_{$lng} AS title,n.id,n.is_ru,n.is_md,n.is_new,n.thumb_md,n.thumb_ru, 
              n.thumb_en 
              FROM news AS n 
              LEFT JOIN news_categories AS nc ON nc.news_id=n.id 
              WHERE n.is_{$lng} = 1 AND n.date_show < '" . date(MYSQL_DATE_FORMAT) . "' 
              AND nc.categories_id = {$categoryId} 
              ORDER BY n.date_show DESC LIMIT 0," . $limit); 

      if (count($items)) { 
       $this->_cache->save($cache_key, $items); 
       return $items; 
      } 
     } 
    } catch (\Exception $e) { 
     return $this->getAll($lng, 20); 
    } 
} 
関連する問題