Exemple #1
0
 function createNouvelle(Nouvelle $n, $RSS_id)
 {
     if ($this->readNouvellefromTitre($n->getTitre(), $RSS_id) == NULL) {
         $safeId = $this->db->quote($RSS_id);
         $safePubDate = $this->db->quote($n->getDate());
         $safeTitre = $this->db->quote($n->getTitre());
         $safeDescription = $this->db->quote($n->getDescription());
         $safeLink = $this->db->quote($n->getUrl());
         $safeImage = $this->db->quote($n->getImage());
         $query = "INSERT INTO Nouvelle (date, titre, description, url, image, RSS_id) " . "VALUES ({$safePubDate}, {$safeTitre}, {$safeDescription}, {$safeLink}, {$safeImage}, {$safeId})";
         try {
             $result = $this->db->exec($query);
             if ($result == 0) {
                 die("Error: nouvelle not inserted\n");
             }
         } catch (Exception $ex) {
             die("PDO Error :" . $ex->getMessage());
         }
     }
     $this->updateImageNouvelle($n, $RSS_id);
 }
Exemple #2
0
 function createNouvelle(Nouvelle $n, $RSS_id)
 {
     $o = $this->readNouvellefromTitre($n->getTitre(), $RSS_id);
     if ($o == NULL) {
         $q = "INSERT INTO nouvelle (date, titre, description, url, image, RSS_id) VALUES (\"" . htmlspecialchars($n->getPubDate()) . "\", \"" . htmlspecialchars($n->getTitre()) . "\", \"" . htmlspecialchars($n->getDescription()) . "\", \"" . htmlspecialchars($n->getLink()) . "\", \"" . htmlspecialchars($n->getImage()) . "\", " . $RSS_id . ")";
         try {
             $r = $this->db->exec($q);
             if ($r == 0) {
                 echo "createRSS error: no rss inserted\n";
             }
             return $this->readRSSfromURL($n->getLink());
         } catch (PDOException $e) {
             echo "PDO Error :" . $e->getMessage();
         }
     } else {
         return $n;
     }
 }