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


PHP get_used_table_names函数代码示例

本文整理汇总了PHP中get_used_table_names函数的典型用法代码示例。如果您正苦于以下问题:PHP get_used_table_names函数的具体用法?PHP get_used_table_names怎么用?PHP get_used_table_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_used_table_names函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drop_plugin_tables

/**
 * Delete all plugin tables
 * @name string name of plugin, used as table prefix
 * @file string path to install.xml file
 * @feedback boolean
 */
function drop_plugin_tables($name, $file, $feedback = true)
{
    global $CFG, $DB;
    // first try normal delete
    if (file_exists($file) and $DB->get_manager()->delete_tables_from_xmldb_file($file)) {
        return true;
    }
    // then try to find all tables that start with name and are not in any xml file
    $used_tables = get_used_table_names();
    $tables = $DB->get_tables();
    /// Iterate over, fixing id fields as necessary
    foreach ($tables as $table) {
        if (in_array($table, $used_tables)) {
            continue;
        }
        if (strpos($table, $name) !== 0) {
            continue;
        }
        // found orphan table --> delete it
        if ($DB->get_manager()->table_exists($table)) {
            $xmldb_table = new xmldb_table($table);
            $DB->get_manager()->drop_table($xmldb_table);
        }
    }
    return true;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:32,代码来源:adminlib.php

示例2: drop_plugin_tables

/**
 * Delete all plugin tables
 * @name string name of plugin, used as table prefix
 * @file string path to install.xml file
 * @feedback boolean
 */
function drop_plugin_tables($name, $file, $feedback = true)
{
    global $CFG, $db;
    // first try normal delete
    if (delete_tables_from_xmldb_file($file, $feedback)) {
        return true;
    }
    // then try to find all tables that start with name and are not in any xml file
    $used_tables = get_used_table_names();
    $tables = $db->MetaTables();
    /// Iterate over, fixing id fields as necessary
    foreach ($tables as $table) {
        if (strlen($CFG->prefix)) {
            if (strpos($table, $CFG->prefix) !== 0) {
                continue;
            }
            $table = substr($table, strlen($CFG->prefix));
        }
        $table = strtolower($table);
        if (strpos($table, $name) !== 0) {
            continue;
        }
        if (in_array($table, $used_tables)) {
            continue;
        }
        // found orphan table --> delete it
        $table = new XMLDBTable($table);
        if (table_exists($table)) {
            drop_table($table, true, $feedback);
        }
    }
    return true;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:39,代码来源:ddllib.php


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