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


PHP db_extend函数代码示例

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


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

示例1: mobi_table_exist

function mobi_table_exist($table_name)
{
    global $smcFunc, $db_prefix, $db_name;
    $tb_prefix = preg_replace('/`' . $db_name . '`./', '', $db_prefix);
    db_extend();
    $tables = $smcFunc['db_list_tables'](false, $tb_prefix . "tapatalk_users");
    return !empty($tables);
}
开发者ID:keweiliu6,项目名称:test-smf2,代码行数:8,代码来源:push.php

示例2: file_source

/**
* file_source()
*
* - initialises all the basic context required for the database cleanup.
* - passes execution onto the relevant section.
* - if the passed action is not found it shows the main page.
*
* @return
*/
function file_source()
{
    global $smcFunc, $context, $table_prefix, $version;
    // You have to be allowed to do this
    isAllowedTo('admin_forum');
    // SMF 1 or 2 ?
    if (isset($smcFunc)) {
        db_extend('packages');
        $version = 2;
        $table_prefix = '{db_prefix}';
    } else {
        db_compat();
        $version = 1;
        $table_prefix = '';
    }
    $actions = array('examine' => 'examine', 'execute' => 'execute');
    $titles = array('examine' => 'Examine Database', 'execute' => 'Execute Changes');
    // Set a default action if none or an unsupported one is given
    if (!isset($_GET['action']) || !isset($actions[$_GET['action']])) {
        $current_action = 'examine';
    } else {
        $current_action = $actions[$_GET['action']];
    }
    // Set up the template information and language
    loadtext();
    $context['sub_template'] = $current_action;
    $context['page_title'] = $titles[$current_action];
    $context['page_title_html_safe'] = $titles[$current_action];
    $context['robot_no_index'] = true;
    $context['html_headers'] .= '
	<style type="text/css">
		.normallist li
		{
			list-style: circle;
			line-height: 1.5em;
		}
		.submit_button
		{
			text-align: center;
		}
		.error
		{
			background-color: #FFECEC;
		}
		.success
		{
			color: #00CC00;
		}
		.fail
		{
			color: #EE0000;
		}
	</style>';
    $current_action();
}
开发者ID:rhodefey,项目名称:tools,代码行数:64,代码来源:databasecleanup.php

示例3: db_packages_init

function db_packages_init()
{
    global $reservedTables, $db_package_log, $db_prefix;
    $db_package_log = array();
    // We setup an array of SMF tables we can't do auto-remove on - in case a mod writer cocks it up!
    $reservedTables = array('admin_info_files', 'approval_queue', 'attachments', 'ban_groups', 'ban_items', 'board_permissions', 'boards', 'calendar', 'calendar_holidays', 'categories', 'collapsed_categories', 'custom_fields', 'group_moderators', 'log_actions', 'log_activity', 'log_banned', 'log_boards', 'log_digest', 'log_errors', 'log_floodcontrol', 'log_group_requests', 'log_karma', 'log_mark_read', 'log_notify', 'log_online', 'log_packages', 'log_polls', 'log_reported', 'log_reported_comments', 'log_scheduled_tasks', 'log_search_messages', 'log_search_results', 'log_search_subjects', 'log_search_topics', 'log_topics', 'mail_queue', 'membergroups', 'members', 'message_icons', 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', 'themes', 'topics');
    foreach ($reservedTables as $k => $table_name) {
        $reservedTables[$k] = strtolower($db_prefix . $table_name);
    }
    // We in turn may need the extra stuff.
    db_extend('extra');
}
开发者ID:norv,项目名称:EosAlpha,代码行数:12,代码来源:DbPackages-mysql.php

示例4: getServerVersions

function getServerVersions($checkFor)
{
    global $txt, $db_connection, $_PHPA, $smcFunc, $memcached, $modSettings;
    loadLanguage('Admin');
    $versions = array();
    // Is GD available?  If it is, we should show version information for it too.
    if (in_array('gd', $checkFor) && function_exists('gd_info')) {
        $temp = gd_info();
        $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']);
    }
    // Now lets check for the Database.
    if (in_array('db_server', $checkFor)) {
        db_extend();
        if (!isset($db_connection) || $db_connection === false) {
            trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
        } else {
            $versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $smcFunc['db_title']), 'version' => '');
            $versions['db_server']['version'] = $smcFunc['db_get_version']();
        }
    }
    // If we're using memcache we need the server info.
    if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        get_memcached_server();
    }
    // Check to see if we have any accelerators installed...
    if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) {
        $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION);
    }
    if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) {
        $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION);
    }
    if (in_array('phpa', $checkFor) && isset($_PHPA)) {
        $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
    }
    if (in_array('apc', $checkFor) && extension_loaded('apc')) {
        $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
    }
    if (in_array('memcache', $checkFor) && function_exists('memcache_set')) {
        $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached));
    }
    if (in_array('xcache', $checkFor) && function_exists('xcache_set')) {
        $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
    }
    if (in_array('php', $checkFor)) {
        $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION);
    }
    if (in_array('server', $checkFor)) {
        $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']);
    }
    return $versions;
}
开发者ID:valek0972,项目名称:hackits,代码行数:51,代码来源:Subs-Admin.php

示例5: protected_alter

function protected_alter($change, $substep, $is_test = false)
{
    global $db_prefix, $smcFunc;
    db_extend('packages');
    // Firstly, check whether the current index/column exists.
    $found = false;
    if ($change['type'] === 'column') {
        $columns = $smcFunc['db_list_columns']('{db_prefix}' . $change['table'], true);
        foreach ($columns as $column) {
            // Found it?
            if ($column['name'] === $change['name']) {
                $found |= 1;
                // Do some checks on the data if we have it set.
                if (isset($change['col_type'])) {
                    $found &= $change['col_type'] === $column['type'];
                }
                if (isset($change['null_allowed'])) {
                    $found &= $column['null'] == $change['null_allowed'];
                }
                if (isset($change['default'])) {
                    $found &= $change['default'] === $column['default'];
                }
            }
        }
    } elseif ($change['type'] === 'index') {
        $request = upgrade_query('
			SHOW INDEX
			FROM ' . $db_prefix . $change['table']);
        if ($request !== false) {
            $cur_index = array();
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                if ($row['Key_name'] === $change['name']) {
                    $cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
                }
            }
            ksort($cur_index, SORT_NUMERIC);
            $found = array_values($cur_index) === $change['target_columns'];
            $smcFunc['db_free_result']($request);
        }
    }
    // If we're trying to add and it's added, we're done.
    if ($found && in_array($change['method'], array('add', 'change'))) {
        return true;
    } elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
        return true;
    } elseif ($is_test) {
        return false;
    }
    // Not found it yet? Bummer! How about we see if we're currently doing it?
    $running = false;
    $found = false;
    while (1 == 1) {
        $request = upgrade_query('
			SHOW FULL PROCESSLIST');
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
                $found = true;
            }
        }
        // Can't find it? Then we need to run it fools!
        if (!$found && !$running) {
            $smcFunc['db_free_result']($request);
            $success = upgrade_query('
				ALTER TABLE ' . $db_prefix . $change['table'] . '
				' . $change['text'], true) !== false;
            if (!$success) {
                return false;
            }
            // Return
            $running = true;
        } elseif (!$found) {
            $smcFunc['db_free_result']($request);
            return true;
        }
        // Pause execution for a sec or three.
        sleep(3);
        // Can never be too well protected.
        nextSubstep($substep);
    }
    // Protect it.
    nextSubstep($substep);
}
开发者ID:norv,项目名称:EosAlpha,代码行数:82,代码来源:eos_upgrade.php

示例6: findSearchAPI

/**
 * Creates a search API and returns the object.
 *
 */
function findSearchAPI()
{
    global $sourcedir, $modSettings, $search_versions, $searchAPI, $txt;
    require_once $sourcedir . '/Subs-Package.php';
    // Search has a special database set.
    db_extend('search');
    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
        fatal_lang_error('search_api_missing');
    }
    require_once $sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php';
    // Create an instance of the search API and check it is valid for this version of SMF.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();
    // An invalid Search API.
    if (!$searchAPI || $searchAPI->supportsMethod('isValid') && !$searchAPI->isValid() || !matchPackageVersion($search_versions['forum_version'], $searchAPI->min_smf_version . '-' . $searchAPI->version_compatible)) {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');
        require_once $sourcedir . '/SearchAPI-Standard.php';
        $searchAPI = new standard_search();
    }
    return $searchAPI;
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:29,代码来源:Search.php

示例7: OptimizeTables

function OptimizeTables()
{
    global $db_type, $db_name, $db_prefix, $txt, $context, $scripturl, $sourcedir, $smcFunc;
    isAllowedTo('admin_forum');
    checkSession('post');
    ignore_user_abort(true);
    db_extend();
    // Start with no tables optimized.
    $opttab = 0;
    $context['page_title'] = $txt['database_optimize'];
    $context['sub_template'] = 'optimize';
    // Only optimize the tables related to this smf install, not all the tables in the db
    $real_prefix = preg_match('~^(`?)(.+?)\\1\\.(.*?)$~', $db_prefix, $match) === 1 ? $match[3] : $db_prefix;
    // Get a list of tables, as well as how many there are.
    $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%');
    $tables = array();
    foreach ($temp_tables as $table) {
        $tables[] = array('table_name' => $table);
    }
    // If there aren't any tables then I believe that would mean the world has exploded...
    $context['num_tables'] = count($tables);
    if ($context['num_tables'] == 0) {
        fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
    }
    // For each table....
    $context['optimized_tables'] = array();
    foreach ($tables as $table) {
        // Optimize the table!  We use backticks here because it might be a custom table.
        $data_freed = $smcFunc['db_optimize_table']($table['table_name']);
        // Optimizing one sqlite table optimizes them all.
        if ($db_type == 'sqlite') {
            break;
        }
        if ($data_freed > 0) {
            $context['optimized_tables'][] = array('name' => $table['table_name'], 'data_freed' => $data_freed);
        }
    }
    // Number of tables, etc....
    $txt['database_numb_tables'] = sprintf($txt['database_numb_tables'], $context['num_tables']);
    $context['num_tables_optimized'] = count($context['optimized_tables']);
    // Check that we don't auto optimise again too soon!
    require_once $sourcedir . '/ScheduledTasks.php';
    CalculateNextTrigger('auto_optimize', true);
}
开发者ID:chenhao6593,项目名称:smf,代码行数:44,代码来源:ManageMaintenance.php

示例8: dirname

* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) {
    require_once dirname(__FILE__) . '/SSI.php';
} elseif (!defined('SMF')) {
    die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
}
db_extend('packages');
$smcFunc['db_add_column']('{db_prefix}polls', array('name' => 'id_topic', 'type' => 'mediumint', 'size' => 8, 'null' => false, 'default' => 0, 'auto' => false, 'unsigned' => true));
$smcFunc['db_change_column']('{db_prefix}polls', 'id_topic', array('unsigned' => true));
// Let's get all our indexes.
$indexes = $smcFunc['db_list_indexes']('{db_prefix}polls', true);
// Do we already have it?
foreach ($indexes as $index) {
    if ($index['name'] == 'id_topic') {
        // If we want to overwrite simply remove the current one then continue.
        $smcFunc['db_remove_index']('{db_prefix}polls', 'id_topic');
    }
}
$smcFunc['db_add_index']('{db_prefix}polls', array('columns' => array('id_topic')));
$request = $smcFunc['db_query']('', '
	SELECT p.id_poll
	FROM {db_prefix}polls AS p
开发者ID:RunasSudo,项目名称:AdditionalPolls,代码行数:31,代码来源:install2.php

示例9: KB_ImportSMFarticle

function KB_ImportSMFarticle()
{
    global $smcFunc, $context, $txt, $db_prefix;
    $context['import_results'] = '';
    $context['sub_template'] = 'kbimportasmfa';
    $dbresult = $smcFunc['db_query']('', "\n\t    SELECT \n\t\t\tc.kbid, c.name\n\t\tFROM {db_prefix}kb_category AS c \n\t\tORDER BY c.name ASC");
    $context['kb_cat'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($dbresult)) {
        $context['kb_cat'][] = $row;
    }
    $smcFunc['db_free_result']($dbresult);
    if (isset($_REQUEST['doimport'])) {
        checkSession();
        $cat = (int) $_REQUEST['catid'];
        db_extend();
        $articles_tables = $smcFunc['db_list_tables'](false, $db_prefix . 'articles');
        if (empty($articles_tables)) {
            fatal_lang_error('kb_importytp4', false);
        }
        if (empty($cat)) {
            fatal_lang_error('kb_importtp1');
        }
        $result = $smcFunc['db_query']('', '
		    SELECT 
			a.ID_MEMBER, a.title, p.pagetext, a.views, a.approved, a.date
		    FROM {db_prefix}articles AS a
			LEFT JOIN {db_prefix}articles_page AS p ON (a.ID_ARTICLE = p.ID_ARTICLE)', array());
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $smcFunc['db_insert']('', '{db_prefix}kb_articles', array('id_member' => 'int', 'title' => 'string', 'content' => 'string', 'views' => 'int', 'approved' => 'int', 'date' => 'int'), array($row['ID_MEMBER'], $row['title'], $row['pagetext'], $row['views'], $row['approved'], $row['date']), array());
        }
        $smcFunc['db_free_result']($result);
        KB_cleanCache();
        $result = $smcFunc['db_query']('', '
		    SELECT 
			k.kbnid, k.title 
		    FROM {db_prefix}kb_articles AS k, {db_prefix}articles AS a
		    WHERE a.ID_MEMBER = k.id_member AND k.date = a.date AND a.title = k.title', array());
        $context['import_results'] = '<strong>' . $txt['kb_import1'] . '</strong><br />';
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $context['import_results'] .= $row['title'] . '<br />';
            $smcFunc['db_query']('', '
				UPDATE {db_prefix}kb_articles
				SET
				id_cat = {int:cat}
				WHERE kbnid = {int:kbid}', array('kbid' => (int) $row['kbnid'], 'cat' => $cat));
        }
        $smcFunc['db_free_result']($result);
    }
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:49,代码来源:KBAdmin.php

示例10: PlushSearch2

function PlushSearch2()
{
    global $scripturl, $modSettings, $sourcedir, $txt, $db_connection;
    global $user_info, $context, $options, $messages_request, $boards_can;
    global $excludedWords, $participants, $smcFunc, $search_versions, $searchAPI;
    if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
        fatal_lang_error('loadavg_search_disabled', false);
    }
    // No, no, no... this is a bit hard on the server, so don't you go prefetching it!
    if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
        ob_end_clean();
        header('HTTP/1.1 403 Forbidden');
        die;
    }
    $weight_factors = array('frequency', 'age', 'length', 'subject', 'first_message', 'sticky');
    $weight = array();
    $weight_total = 0;
    foreach ($weight_factors as $weight_factor) {
        $weight[$weight_factor] = empty($modSettings['search_weight_' . $weight_factor]) ? 0 : (int) $modSettings['search_weight_' . $weight_factor];
        $weight_total += $weight[$weight_factor];
    }
    // Zero weight.  Weightless :P.
    if (empty($weight_total)) {
        fatal_lang_error('search_invalid_weights');
    }
    // These vars don't require an interface, they're just here for tweaking.
    $recentPercentage = 0.3;
    $humungousTopicPosts = 200;
    $maxMembersToSearch = 500;
    $maxMessageResults = empty($modSettings['search_max_results']) ? 0 : $modSettings['search_max_results'] * 5;
    // Start with no errors.
    $context['search_errors'] = array();
    // Number of pages hard maximum - normally not set at all.
    $modSettings['search_max_results'] = empty($modSettings['search_max_results']) ? 200 * $modSettings['search_results_per_page'] : (int) $modSettings['search_max_results'];
    // Maximum length of the string.
    $context['search_string_limit'] = 100;
    loadLanguage('Search');
    if (!isset($_REQUEST['xml'])) {
        loadTemplate('Search');
    } else {
        $context['sub_template'] = 'results';
    }
    // Are you allowed?
    isAllowedTo('search_posts');
    require_once $sourcedir . '/Display.php';
    require_once $sourcedir . '/Subs-Package.php';
    // Search has a special database set.
    db_extend('search');
    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
        fatal_lang_error('search_api_missing');
    }
    loadClassFile('SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
    // Create an instance of the search API and check it is valid for this version of SMF.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();
    if (!$searchAPI || $searchAPI->supportsMethod('isValid') && !$searchAPI->isValid() || !matchPackageVersion($search_versions['forum_version'], $searchAPI->min_smf_version . '-' . $searchAPI->version_compatible)) {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');
        loadClassFile('SearchAPI-Standard.php');
        $searchAPI = new standard_search();
    }
    // $search_params will carry all settings that differ from the default search parameters.
    // That way, the URLs involved in a search page will be kept as short as possible.
    $search_params = array();
    if (isset($_REQUEST['params'])) {
        // Due to IE's 2083 character limit, we have to compress long search strings
        $temp_params = base64_decode(str_replace(array('-', '_', '.'), array('+', '/', '='), $_REQUEST['params']));
        // Test for gzuncompress failing
        $temp_params2 = @gzuncompress($temp_params);
        $temp_params = explode('|"|', !empty($temp_params2) ? $temp_params2 : $temp_params);
        foreach ($temp_params as $i => $data) {
            @(list($k, $v) = explode('|\'|', $data));
            $search_params[$k] = $v;
        }
        if (isset($search_params['brd'])) {
            $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
        }
    }
    // Store whether simple search was used (needed if the user wants to do another query).
    if (!isset($search_params['advanced'])) {
        $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
    }
    // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
    if (!empty($search_params['searchtype']) || !empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2) {
        $search_params['searchtype'] = 2;
    }
    // Minimum age of messages. Default to zero (don't set param in that case).
    if (!empty($search_params['minage']) || !empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0) {
        $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
    }
    // Maximum age of messages. Default to infinite (9999 days: param not set).
    if (!empty($search_params['maxage']) || !empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999) {
        $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
    }
    // Searching a specific topic?
    if (!empty($_REQUEST['topic'])) {
        $search_params['topic'] = (int) $_REQUEST['topic'];
//.........这里部分代码省略.........
开发者ID:chenhao6593,项目名称:smf,代码行数:101,代码来源:Search.php

示例11: alterTable

function alterTable($tableName, $knownKeys = '', $knownColumns = '', $alterColumns = '', $reverseKeys = false, $reverseColumns = false)
{
    global $smcFunc, $to_prefix;
    // Ok, you old scripts. Get off it!
    print_error('alterTable is deprecated in convert.php. Please consider using proper \\$smcFuncs.' . var_dump(function_exists('debug_backtrace') ? debug_backtrace() : 'Unable to backtrace'));
    // Shorten this up
    $to_table = $to_prefix . $tableName;
    // Get Packing!
    db_extend('packages');
    // Get the keys
    if (!empty($knownKeys)) {
        $availableKeys = array_flip($smcFunc['db_list_indexes']());
    } else {
        $knownKeys = array();
    }
    // Are we dealing with columns also?
    if (!empty($knownColumns)) {
        $availableColumns = array_flip($smcFunc['db_list_columns']("{$tableName}", true));
    } else {
        $knownColumns = array();
    }
    // Column to alter
    if (!empty($alterColumns) && is_array($alterColumns)) {
        $alterColumns = $alterColumns;
    } else {
        $alterColumns = array();
    }
    // Check indexes
    foreach ($knownKeys as $key => $value) {
        // If we are dropping keys then it should unset the known keys if it's NOT available
        if ($reverseKeys == false && !in_array($key, $availableKeys)) {
            unset($knownKeys[$key], $knownKeys[$key]);
        } elseif ($reverseKeys == true && in_array($key, $availableKeys)) {
            unset($knownKeys[$key], $knownKeys[$key]);
        }
    }
    // Check columns
    foreach ($knownColumns as $column => $value) {
        // Here we reverse things.  If the column is not in then we must add it.
        if ($reverseColumns == false && in_array($column, $availableColumns)) {
            unset($knownColumns[$column], $knownColumns[$column]);
        } elseif ($reverseColumns == true && !in_array($column, $availableColumns)) {
            unset($knownColumns[$column], $knownColumns[$column]);
        }
    }
    // Now merge the three
    $alter = array_merge($alterColumns, $knownKeys, $knownColumns);
    // Now lets see what we want to do with them
    $clause = '';
    foreach ($alter as $key) {
        $clause .= "\n\t\t{$key},";
    }
    // Lets do some altering
    convert_query("\n\t\tALTER TABLE {$to_table}" . substr($clause, 0, -1));
}
开发者ID:Realms-Network,项目名称:Vanilla-2-to-SMF-2,代码行数:55,代码来源:convert.php

示例12: get_database_version

/**
 * Determine a few things about the database
 * - collation
 * - name
 * - version
 */
function get_database_version()
{
    global $db_type, $context, $db_name, $txt, $db_prefix;
    $db = database();
    if (empty($db_type) || !empty($db_type) && $db_type == 'mysql') {
        $temp_prefix = (strpos($db_prefix, $db_name) === false ? '`' . $db_name . '`.' : '') . $db_prefix;
        // Get the collation of the 'body' field of the messages table
        $query = ' SHOW FULL COLUMNS FROM ' . $temp_prefix . 'messages WHERE Field = \'body\'';
        $request = $db->query('', $query);
        $row = $db->fetch_assoc($request);
        if (!empty($row)) {
            $collation = $row['Collation'];
        }
    }
    $context['character_set'] = !empty($collation) ? $collation : $txt['unknown_db_version'];
    db_extend();
    $context['database_version'] = $db->db_title() . ' ' . $db->db_server_version();
}
开发者ID:ahrasis,项目名称:tools,代码行数:24,代码来源:elkinfo.php

示例13: mobi_table_exist

function mobi_table_exist($table_name)
{
    global $smcFunc, $db_prefix;
    db_extend();
    $tables = $smcFunc['db_list_tables'](false, $db_prefix . $table_name);
    return !empty($tables);
}
开发者ID:keweiliu6,项目名称:test-smf2,代码行数:7,代码来源:mobiquo_common.php

示例14: sortSmileyTable

function sortSmileyTable()
{
    global $smcFunc;
    db_extend('packages');
    // Add a sorting column.
    smf_db_add_column('{db_prefix}smileys', array('name' => 'temp_order', 'size' => 8, 'type' => 'mediumint', 'null' => false));
    // Set the contents of this column.
    smf_db_query('
		UPDATE {db_prefix}smileys
		SET temp_order = LENGTH(code)', array());
    // Order the table by this column.
    smf_db_query('
		ALTER TABLE {db_prefix}smileys
		ORDER BY temp_order DESC', array('db_error_skip' => true));
    // Remove the sorting column.
    smf_db_remove_column('{db_prefix}smileys', 'temp_order');
}
开发者ID:norv,项目名称:EosAlpha,代码行数:17,代码来源:ManageSmileys.php

示例15: dirname

 * wayne Mankertz.
 * Portions created by the Initial Developer are Copyright (C) 2011
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) {
    require_once dirname(__FILE__) . '/SSI.php';
} elseif (!defined('SMF')) {
    die('<strong>Error:</strong> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
}
global $db_prefix, $modSettings, $smcFunc;
// First load the SMF 2's Extra DB Functions
db_extend('packages');
db_extend('extra');
pre_installCheck();
$GplusHooks = array('integrate_pre_include' => '$sourcedir/GPlus/GPlusHooks.php', 'integrate_buffer' => 'ob_gplus', 'integrate_actions' => 'gplus_actions', 'integrate_profile_areas' => 'gplus_profile_areas', 'integrate_admin_areas' => 'gplus_admin_areas', 'integrate_login' => 'gplus_integrate_login', 'integrate_logout' => 'gplus_integrate_logout', 'integrate_load_theme' => 'gplus_loadTheme');
foreach ($GplusHooks as $hook => $function) {
    add_integration_function($hook, $function);
}
db_add_col('members', 'gpname', 'varchar', 255);
db_add_col('members', 'gpid', 'varchar', 255);
function pre_installCheck()
{
    if (version_compare(PHP_VERSION, '5.2.0', '<')) {
        fatal_error('<strong>PHP 5 or geater is required to install SA Google+.  Please advise your host that PHP4 is no longer maintained and ask that they upgrade you to PHP5.</strong><br />');
    }
}
function db_add_col($table, $col, $type, $size)
{
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:31,代码来源:install.php


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