本文整理匯總了PHP中context::merge_context_temp_table方法的典型用法代碼示例。如果您正苦於以下問題:PHP context::merge_context_temp_table方法的具體用法?PHP context::merge_context_temp_table怎麽用?PHP context::merge_context_temp_table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類context
的用法示例。
在下文中一共展示了context::merge_context_temp_table方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: build_paths
/**
* Rebuild context paths and depths at block context level.
*
* @static
* @param $force
*/
protected static function build_paths($force)
{
global $DB;
if ($force or $DB->record_exists_select('context', "contextlevel = " . CONTEXT_BLOCK . " AND (depth = 0 OR path IS NULL)")) {
if ($force) {
$ctxemptyclause = '';
} else {
$ctxemptyclause = "AND (ctx.path IS NULL OR ctx.depth = 0)";
}
// pctx.path IS NOT NULL prevents fatal problems with broken block instances that point to invalid context parent
$sql = "INSERT INTO {context_temp} (id, path, depth)\n SELECT ctx.id, " . $DB->sql_concat('pctx.path', "'/'", 'ctx.id') . ", pctx.depth+1\n FROM {context} ctx\n JOIN {block_instances} bi ON (bi.id = ctx.instanceid AND ctx.contextlevel = " . CONTEXT_BLOCK . ")\n JOIN {context} pctx ON (pctx.id = bi.parentcontextid)\n WHERE (pctx.path IS NOT NULL AND pctx.depth > 0)\n {$ctxemptyclause}";
$trans = $DB->start_delegated_transaction();
$DB->delete_records('context_temp');
$DB->execute($sql);
context::merge_context_temp_table();
$DB->delete_records('context_temp');
$trans->allow_commit();
}
}
示例2: build_paths
/**
* Rebuild context paths and depths at course category context level.
*
* @static
* @param bool $force
*/
protected static function build_paths($force) {
global $DB;
if ($force or $DB->record_exists_select('context', "contextlevel = " . CONTEXT_COSTCENTER . " AND (depth = 0 OR path IS NULL)")) {
if ($force) {
$ctxemptyclause = $emptyclause = '';
} else {
$ctxemptyclause = "AND (ctx.path IS NULL OR ctx.depth = 0)";
$emptyclause = "AND ({context}.path IS NULL OR {context}.depth = 0)";
}
$base = '/' . SYSCONTEXTID;
// Normal top level categories
$sql = "UPDATE {context}
SET depth=2,
path=" . $DB->sql_concat("'$base/'", 'id') . "
WHERE contextlevel=" . CONTEXT_COSTCENTER . "
AND EXISTS (SELECT 'x'
FROM {local_costcenter} cc
WHERE cc.id = {context}.instanceid AND cc.depth=1)
$emptyclause";
$DB->execute($sql);
// Deeper categories - one query per depthlevel
$maxdepth = $DB->get_field_sql("SELECT MAX(depth) FROM {local_costcenter}");
for ($n = 2; $n <= $maxdepth; $n++) {
$sql = "INSERT INTO {context_temp} (id, path, depth)
SELECT ctx.id, " . $DB->sql_concat('pctx.path', "'/'", 'ctx.id') . ", pctx.depth+1
FROM {context} ctx
JOIN {local_costcenter} cc ON (cc.id = ctx.instanceid AND ctx.contextlevel = " . CONTEXT_COSTCENTER . " AND cc.depth = $n)
JOIN {context} pctx ON (pctx.instanceid = cc.parent AND pctx.contextlevel = " . CONTEXT_COSTCENTER . ")
WHERE pctx.path IS NOT NULL AND pctx.depth > 0
$ctxemptyclause";
$trans = $DB->start_delegated_transaction();
$DB->delete_records('context_temp');
$DB->execute($sql);
context::merge_context_temp_table();
$DB->delete_records('context_temp');
$trans->allow_commit();
}
}
}