本文整理匯總了PHP中UrlManager::addCourseCategoryToUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlManager::addCourseCategoryToUrl方法的具體用法?PHP UrlManager::addCourseCategoryToUrl怎麽用?PHP UrlManager::addCourseCategoryToUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UrlManager
的用法示例。
在下文中一共展示了UrlManager::addCourseCategoryToUrl方法的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);
}
}
}
}
}