当前位置: 首页>>代码示例>>PHP>>正文


PHP context::merge_context_temp_table方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:25,代码来源:accesslib.php

示例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();
            }
        }
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:49,代码来源:accesslib.php


注:本文中的context::merge_context_temp_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。