Пример #1
0
 public function addArticle(Application_Model_Entity_Article $article)
 {
     $border = date('Y-m-d H:i:s', strtotime('-1 day'));
     $result = $this->_db->query('SELECT id FROM ' . $this->_table . ' WHERE feadId=? AND (dateCreated=? OR ' . 'title=? OR content=?) AND dateModified>? ORDER BY dateModified DESC', [$article->getFeadid(), $article->getDateCreated(), $article->getTitle(), $article->getContent(), $border])->fetch();
     if (!$result) {
         $this->_db->insert($this->_table, ['feadId' => $article->getFeadId(), 'title' => $article->getTitle(), 'preview' => $article->getPreview(), 'url' => $article->getUrl(), 'thumb' => $article->getThumb(), 'dateCreated' => $article->getDateCreated(), 'dateModified' => $article->getDate(), 'content' => $article->getContent(), 'guid' => $article->getGuid()]);
     } else {
         $this->_db->update($this->_table, ['feadId' => $article->getFeadId(), 'title' => $article->getTitle(), 'preview' => $article->getPreview(), 'url' => $article->getUrl(), 'dateModified' => $article->getDate(), 'content' => $article->getContent()], $this->_db->quoteInto('id=?', [$result['id']]));
     }
 }