예제 #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);
 }
예제 #2
0
 function updateImageNouvelle(Nouvelle $n)
 {
     // Met à jour uniquement le titre et la date
     $titre = $this->db->quote($n->getTitre());
     $q = "UPDATE RSS SET titre={$titre}, date='" . $n->getPubDate() . "' WHERE url='" . $rss->getLink() . "'";
     try {
         $r = $this->db->exec($q);
         if ($r == 0) {
             echo "updateRSS error: no rss updated\n";
         }
     } catch (PDOException $e) {
         echo "PDO Error :" . $e->getMessage();
     }
 }