Esempio n. 1
0
 function delete($report)
 {
     parent::delete($report, self::OBJECT_CLASS);
     $rs = $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::REPORT_ID), Operator::EQUAL, intval($report->getID())))), $this->table->getName(), $report);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando il dato. Riprovare.");
     }
     return $report;
 }
Esempio n. 2
0
 function delete($comm)
 {
     parent::delete($comm, self::OBJECT_CLASS);
     $rs = $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::COMMENT_ID), Operator::EQUAL, $comm->getID()))), $this->table->getName(), $comm);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Errore durante l'eliminazione dell'oggetto.");
     }
     return $comm;
 }
Esempio n. 3
0
 function delete($author, $post)
 {
     parent::delete($author, "User");
     parent::delete($author, "Post");
     $rs = $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::VOTE_AUTHOR), Operator::EQUAL, intval($author->getID())), new WhereConstraint($this->table->getColumn(DB::VOTE_POST), Operator::EQUAL, intval($post->getID())))), $this->table->getName(), array("Vote", intval($author->getID()), intval($post->getID())));
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando l'oggetto. Riprovare.");
     }
     return true;
 }
Esempio n. 4
0
 function delete($contact)
 {
     parent::delete($contact, self::OBJECT_CLASS);
     $this->db->execute(Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::CONTACT_ID), Operator::EQUAL, $contact->getID()))), $this->table->getName(), $contact);
     //salvo la risorsa nella storia.
     $this->saveHistory($contact, "DELETED");
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando il dato. Riprovare.");
     }
     return $contact;
 }
Esempio n. 5
0
 function delete($user)
 {
     parent::delete($user, self::OBJECT_CLASS);
     //carico la risorsa, completa dei suoi derivati (che andrebbero persi).
     $loadR = $this->loadReports;
     $this->loadReports = true;
     $loadD = $this->loadDependences;
     $this->loadDependences = true;
     $u_complete = null;
     try {
         $u_complete = $this->load($user->getID());
         $this->loadReports = $loadR;
         $this->loadDependences = $loadD;
     } catch (Exception $e) {
         $this->loadReports = $loadR;
         $this->loadDependences = $loadD;
         throw $e;
     }
     $this->db->execute(Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::USER_ID), Operator::EQUAL, $user->getID()))), $this->table->getName(), $user);
     //salvo la risorsa nella storia.
     $this->saveHistory($u_complete, "DELETED");
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando il dato. Riprovare.");
     }
     return $user;
 }
Esempio n. 6
0
 function delete($post)
 {
     parent::delete($post, self::OBJECT_CLASS);
     //carico il post, completo dei suoi derivati (che andrebbero persi) esclusi i voti.
     $loadC = $this->loadComments;
     $this->loadComments = true;
     $loadR = $this->loadReports;
     $this->loadReports = true;
     $p_complete = null;
     try {
         $p_complete = $this->load($post->getID());
         $this->loadComments = $loadC;
         $this->loadReports = $loadR;
     } catch (Exception $e) {
         $this->loadComments = $loadC;
         $this->loadReports = $loadR;
         throw $e;
     }
     $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::POST_ID), Operator::EQUAL, $post->getID()))), $this->table->getName(), $post);
     //salvo il post nella storia.
     $this->saveHistory($p_complete, "DELETED");
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando il dato. Riprovare.");
     }
     return $post;
 }
 public function delete($id)
 {
     $arr_id = array("id" => $id);
     return parent::delete($arr_id);
 }
Esempio n. 8
0
 function unsubscribePost($post, $contest)
 {
     parent::delete($contest, self::OBJECT_CLASS);
     if (!is_subclass_of($post, "Post")) {
         throw new Exception("Attenzione! Il parametro di ricerca non è un post.");
     }
     if (time() > $contest->getEnd()) {
         throw new Exception("Questo contest è chiuso, non puoi cancellare la tua iscrizione.");
     }
     $this->db->execute($s = Query::generateDeleteStm($this->table_cs, array(new WhereConstraint($this->table_cs->getColumn(DB::CONTEST_SUBSCRIBER_POST), Operator::EQUAL, $post->getID()), new WhereConstraint($this->table_cs->getColumn(DB::CONTEST_SUBSCRIBER_CONTEST), Operator::EQUAL, $this->getID()))), $this->table_cs->getName(), $contest);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore eliminando l'oggetto. Riprovare.");
     }
     //$this->loadSubscribers($contest); //FIXME vale la pena ricaricare il contest?
     return $contest;
 }