本文整理汇总了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;
}
示例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;
}