ArticleTopic::RemoveTopicFromArticles PHP Method

RemoveTopicFromArticles() public static method

Unlink a topic from all articles.
public static RemoveTopicFromArticles ( integer $p_topicId ) : void
$p_topicId integer
return void
    public static function RemoveTopicFromArticles($p_topicId)
    {
        global $g_ado_db;
        $queryStr = "DELETE FROM ArticleTopics WHERE TopicId={$p_topicId}";
        $g_ado_db->Execute($queryStr);
    }

Usage Example

Example #1
0
}
if ($f_confirmed == 1) {
    // get a list of subtopics
    $deleteTopics = $deleteTopic->getSubtopics();
    // detach all subtopics from all articles
    foreach ($deleteTopics as $topic) {
        ArticleTopic::RemoveTopicFromArticles($topic->getTopicId());
    }
    // delete all subtopics
    foreach ($deleteTopics as $topic) {
        $topic->delete($f_topic_language_id);
    }
    $doDelete = true;
}
if ($doDelete) {
    ArticleTopic::RemoveTopicFromArticles($deleteTopic->getTopicId());
    $deleted = $deleteTopic->delete($f_topic_language_id);
    if ($deleted) {
        camp_html_add_msg(getGS("Topic was deleted."), "ok");
        camp_html_goto_page("/{$ADMIN}/topics/index.php");
    } else {
        $errorMsgs[] = getGS('The topic $1 could not be deleted.', '<B>' . $deleteTopic->getName($f_topic_language_id) . '</B>');
    }
}
$crumbs = array();
$crumbs[] = array(getGS("Configure"), "");
$crumbs[] = array(getGS("Topics"), "/{$ADMIN}/topics/");
$crumbs[] = array(getGS("Deleting topic"), "");
echo camp_html_breadcrumbs($crumbs);
?>