title: How do I correctly create a Zend Feed?
body: <p>I have successfully created a simple RSS feed, but entries keep coming back as unread and updated, and entries deleted from the client reappear everytime I ask mail to update the feed. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>I use this simple function to create an rss feed:</p>
  
  <pre><code>public static function getFeed($db)
  {
      $title = 'Latest feeds';
      $feedUri = '/rss/';
  
      //link from which feed is available
      $link = 'http://' . $_SERVER['HTTP_HOST'] . $feedUri;
  
      //create array according to structure defined in Zend_Feed documentation
      $feedArr = array('title' =&gt; $title,
                       'link'  =&gt; $link,
                       'description' =&gt; $title,
                       'language' =&gt; 'en-us',
                       'charset' =&gt; 'utf-8',
                     //'published' =&gt; 1237281011,
                       'generator' =&gt; 'Zend Framework Zend_Feed',
                       'entries' =&gt; array()
                );
      $itemObjs = array();
      $select = $db-&gt;select('id')-&gt;from('things')
                                 -&gt;order('createddate desc')
                                 -&gt;limit(10);
      $results = $db-&gt;fetchAll($select-&gt;__toString());
      $count = count($results);
      for($i=0;$i&lt;$count;$i++) {
          $itemObjs[] = SiteUtil::getItemObjectInstance($db, $results[$i]['id']);
      }
      $count = count($itemObjs);
      for($i=0;$i&lt;$count;$i++) {
          $obj = &amp; $itemObjs[$i];
          $feedArr['entries'][] = array('title' =&gt; $obj-&gt;getSummary(),
                                        'link'    =&gt; 'http://' . $_SERVER['HTTP_HOST'] . $obj-&gt;getDetailUri(),
                                        'description' =&gt; $obj-&gt;description,
                                        'publishdate' =&gt; $obj-&gt;publishedDate,
                                        'guid' =&gt; 'http://' . $_SERVER['HTTP_HOST'] . $obj-&gt;getDetailUri()
                                        );
      }
      $feed = Zend_Feed::importArray($feedArr, 'rss');
      return $feed;
  }
  </code></pre>
  
  <p>The action in the controller class is:</p>
  
  <pre><code>public function rssAction()
  {
      $feed = FeedUtil::getFeed($this-&gt;db);
      $feed-&gt;send();
  }
  </code></pre>
  
  <p>So to access the feed, I point the client to:
  <a href="http://mysite.com/rss" rel="nofollow noreferrer">http://mysite.com/rss</a></p>
  
  <p>I am using mac mail's rss client to test. The feed downloads just fine, showing all 5 items I have in the database for testing purposes. The problems are as follows:</p>
  
  <p>1) If I mark one or more items as 'read' and then tell mail to update the feed, it pulls all items again as if I never downloaded them in the first place. </p>
  
  <p>2) If I delete one or more items they come back again, unread, again as if it were the first time I subscribed to the feed.</p>
  
  <p>3) Feeds are <em>always</em> marked as updated. Is that supposed to be the case?</p>
  
  <p>Is is something to do with the parameters I'm setting, am I omitting something, or could the solution be something more subtle like setting HTTP content headers (e.g. '304 Not Modified')?</p>
  
  <p>My understanding of rss is that once an item has been marked as read or deleted from the client, it should never come back, which is the behaviour I'm after.</p>
  
  <p>Just to note, the 'link' and 'guid' parameters are always unique, and I have tried experimenting with 'published' and 'publishdate' (both optional) attributes only get the same result. The above code is a simplified version of what I have, showing only the relevant bits, and finally, yes, I have read the <a href="http://cyber.law.harvard.edu/rss/rss.html" rel="nofollow noreferrer">rss specification</a>.</p>
  
  <p>Thanks in advance for any help offered here, I'll be happy to clarify any point.</p>