本文整理汇总了PHP中UrlManager::deleteUrlRelCourseCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlManager::deleteUrlRelCourseCategory方法的具体用法?PHP UrlManager::deleteUrlRelCourseCategory怎么用?PHP UrlManager::deleteUrlRelCourseCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlManager
的用法示例。
在下文中一共展示了UrlManager::deleteUrlRelCourseCategory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUrlRelCourseCategory
/**
* Updates the access_url_rel_course_category table with a given list
* @author Julio Montoya
* @param array course category list
* @param int access_url_id
**/
public static function updateUrlRelCourseCategory($list, $urlId)
{
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$sql = "SELECT course_category_id FROM {$table} WHERE access_url_id = " . intval($urlId);
$result = Database::query($sql);
$existingItems = array();
while ($row = Database::fetch_array($result)) {
$existingItems[] = $row['course_category_id'];
}
// Adding
foreach ($list as $id) {
UrlManager::addCourseCategoryToUrl($id, $urlId);
$categoryInfo = CourseCategoryManager::getCategoryById($id);
$children = CourseCategoryManager::getChildren($categoryInfo['code']);
if (!empty($children)) {
foreach ($children as $category) {
UrlManager::addCourseCategoryToUrl($category['id'], $urlId);
}
}
}
// Deleting old items
foreach ($existingItems as $id) {
if (!in_array($id, $list)) {
UrlManager::deleteUrlRelCourseCategory($id, $urlId);
$categoryInfo = CourseCategoryManager::getCategoryById($id);
$children = CourseCategoryManager::getChildren($categoryInfo['code']);
if (!empty($children)) {
foreach ($children as $category) {
UrlManager::deleteUrlRelCourseCategory($category['id'], $urlId);
}
}
}
}
}