コード例 #1
0
ファイル: suxTags.php プロジェクト: hashimmm/sux0r
 /**
  * Delete tag
  *
  * @param int $id tag id
  */
 function delete($id)
 {
     if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
         return false;
     }
     $tid = suxDB::requestTransaction();
     $this->inTransaction = true;
     $st = $this->db->prepare("DELETE FROM {$this->db_table} WHERE id = ? ");
     $st->execute(array($id));
     // Delete links, too
     $link = new suxLink();
     $links = $link->getLinkTables('tags');
     foreach ($links as $table) {
         $link->deleteLink($table, 'tags', $id);
     }
     suxDB::commitTransaction($tid);
     $this->inTransaction = false;
 }
コード例 #2
0
ファイル: suxRSS.php プロジェクト: hashimmm/sux0r
 /**
  * @param int $id feed id
  */
 function deleteFeed($id)
 {
     if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
         return false;
     }
     $tid = suxDB::requestTransaction();
     $this->inTransaction = true;
     $st = $this->db->prepare("DELETE FROM {$this->db_feeds} WHERE id = ? ");
     $st->execute(array($id));
     $st = $this->db->prepare("SELECT id FROM {$this->db_items} WHERE rss_feeds_id = ? ");
     $st->execute(array($id));
     $result = $st->fetchAll(PDO::FETCH_ASSOC);
     // Used with link deletion
     $st = $this->db->prepare("DELETE FROM {$this->db_items} WHERE rss_feeds_id = ? ");
     $st->execute(array($id));
     // Delete links, too
     $link = new suxLink();
     $links = $link->getLinkTables('rss_feeds');
     foreach ($links as $table) {
         $link->deleteLink($table, 'rss_feeds', $id);
     }
     $links = $link->getLinkTables('rss_items');
     foreach ($links as $table) {
         foreach ($result as $key => $val) {
             $link->deleteLink($table, 'rss_items', $val['id']);
         }
     }
     suxDB::commitTransaction($tid);
     $this->inTransaction = false;
 }
コード例 #3
0
 /**
  * Delete thread
  *
  * @param int $thread_id thread id
  */
 function deleteThread($thread_id)
 {
     if (!filter_var($thread_id, FILTER_VALIDATE_INT) || $thread_id < 1) {
         return false;
     }
     // Begin transaction
     $tid = suxDB::requestTransaction();
     $this->inTransaction = true;
     $st = $this->db->prepare("SELECT id FROM {$this->db_table} WHERE thread_id = ? ");
     $st->execute(array($thread_id));
     $result = $st->fetchAll(PDO::FETCH_ASSOC);
     foreach ($result as $key => $val) {
         $st = $this->db->prepare("DELETE FROM {$this->db_table} WHERE id = ? ");
         $st->execute(array($val['id']));
         $st = $this->db->prepare("DELETE FROM {$this->db_table_hist} WHERE messages_id = ? ");
         $st->execute(array($val['id']));
     }
     // Delete links, too
     $link = new suxLink();
     $links = $link->getLinkTables('messages');
     foreach ($result as $key => $val) {
         foreach ($links as $table) {
             $link->deleteLink($table, 'messages', $val['id']);
         }
     }
     // Commit
     suxDB::commitTransaction($tid);
     $this->inTransaction = false;
 }