2009-06-23 68 views
1
//CODE 
    $entries = $model->fetchEntries(); 

    $feedUri = '/rss/'; 
    //link from which feed is available 
    $link = 'http://' . $_SERVER['HTTP_HOST'] . $feedUri; 


    $feedArray = array(
      'title' => 'Student\'s Movie Club - Upcoming Movies', 
      'link' => $link, 
      'description' => 'Upcoming Movies', 
      'language' => 'en-us', 
      'charset' => 'utf-8', 
      'pubDate' => $entries[0]['created'], 
      'generator' => 'Zend Framework Zend_Feed', 
      'entries' => array() 
     ); 

    foreach ($entries as $movie) { 
     $feedArray['entries'][] = array(
      'title' => $movie['movie_title'], 
      'link' => '/movie/view/id/'.$movie['id'], 
      'description' => $move['movie_review'], 
      'pubDate' => $movie['created'], 
      'guid' => 'http://' . $_SERVER['HTTP_HOST'] .'/movie/view/id/'.$movie['id'] 
      ); 
     } 

    //var_dump($feedArray); 
    //die(); 
    $feed = Zend_Feed::importArray($feedArray, 'rss'); 
    $feed->send(); 
    //~CODE 

沒有與此消息引發異常:那麼Zend_Feed 「描述密鑰丟失」

An error occurred 
Application error 
Exception information: 

Message: description key is missing 

Stack trace: 

#0 C:\wwwroot\projects\studyhood\project2\library\Zend\Feed\Builder.php(182): Zend_Feed_Builder->_createEntries(Array) 
#1 C:\wwwroot\projects\studyhood\project2\library\Zend\Feed.php(385): 

讚賞任何幫助...

回答

2

我相信這是你的問題:

'description' => $move['movie_review'], 

看看$電影的拼寫:)將您的代碼更改爲:

foreach ($entries as $movie) { 
     $feedArray['entries'][] = array(
      'title' => $movie['movie_title'], 
      'link' => '/movie/view/id/'.$movie['id'], 
      'description' => $movie['movie_review'], 
      'pubDate' => $movie['created'], 
      'guid' => 'http://' . $_SERVER['HTTP_HOST'] .'/movie/view/id/'.$movie['id'] 
      ); 
} 
+0

謝謝隊友...還有一件事我找到了..也許我錯了也許不是。如果你在數據庫中有NULL值(例如$ movie ['movie_review'] IS_NULL,那麼你將會遇到同樣的問題.. Cheers。 – Andreas 2009-06-23 19:25:16