/** * * @param <type> $post_id * @param <type> $delete_children */ public function post_delete($post_id, $delete_children = false) { if (!is_numeric($post_id)) { throw new DBForumException('$post_id must be numeric'); } if (!is_bool($delete_children)) { throw new DBForumException('$delete_children must be bool'); } try { if ($delete_children) { $children_ids = $this->db->quick_query( "SELECT ".self::POST_ID." FROM ".self::FCORE_FORUM_POST." WHERE ".self::POSTPARENT."=$post_id AND ".self::FORUM_ID."=$this->forum_id", true); if ($children_ids != null) { foreach($children_ids as $child_id) { $this->post_delete($child_id[self::POST_ID], true); } } } else { $new_parent = $this->db->quick_query( "SELECT ".self::POSTPARENT." FROM ".self::FCORE_FORUM_POST." WHERE ".self::POST_ID."=$post_id AND ".self::FORUM_ID."=$this->forum_id", true); if ($new_parent != null) { $new_parent = $new_parent[0][self::POSTPARENT]; $this->db->quick_query( "UPDATE ".self::FCORE_FORUM_POST." SET ".self::POSTPARENT."=$new_parent WHERE ".self::POSTPARENT."=$post_id AND ".self::FORUM_ID."=$this->forum_id"); } } DBDataType::DeleteDataFromOrigin( self::build_datatype_origin($this->origin_type), $post_id); $this->db->quick_query( "DELETE FROM ".self::FCORE_FORUM_POST." WHERE ".self::POST_ID."=$post_id AND ".self::FORUM_ID."=$this->forum_id"); $this->db->commit(); } catch(Exception $e) { $this->db->rollback(); throw new DBForumException($e->getMessage()); } }