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


PHP SQL::FROM方法代码示例

本文整理汇总了PHP中SQL::FROM方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::FROM方法的具体用法?PHP SQL::FROM怎么用?PHP SQL::FROM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQL的用法示例。


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

示例1: SQL

 /**
  * Get an object from cache by IP address
  *
  * Load into cache if necessary
  *
  * @param string IP address
  * @param boolean false if you want to return false on error
  * @param boolean true if function should die on empty/null
  */
 function &get_by_ip($req_ip, $halt_on_error = false, $halt_on_empty = false)
 {
     global $DB, $Debuglog;
     if (!isset($this->ip_index[$req_ip])) {
         // not yet in cache:
         $IP = ip2int($req_ip);
         $SQL = new SQL('Get ID of IP range by IP address');
         $SQL->SELECT('aipr_ID');
         $SQL->FROM('T_antispam__iprange');
         $SQL->WHERE('aipr_IPv4start <= ' . $DB->quote($IP));
         $SQL->WHERE_and('aipr_IPv4end >= ' . $DB->quote($IP));
         $IPRange_ID = $DB->get_var($SQL->get());
         // Get object from IPRangeCache bi ID
         $IPRange = $this->get_by_ID($IPRange_ID, $halt_on_error, $halt_on_empty);
         if ($IPRange) {
             // It is in IPRangeCache
             $this->ip_index[$req_ip] = $IPRange;
         } else {
             // not in the IPRangeCache
             if ($halt_on_error) {
                 debug_die("Requested {$this->objtype} does not exist!");
             }
             $this->ip_index[$req_ip] = false;
         }
     } else {
         $Debuglog->add("Retrieving <strong>{$this->objtype}({$req_ip})</strong> from cache");
     }
     return $this->ip_index[$req_ip];
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:38,代码来源:_iprangecache.class.php

示例2: fcpf_categories_select

/**
 * Get the categories list
 *
 * @param integer Parent category ID
 * @param integer Level
 * @return array Categories
 */
function fcpf_categories_select($parent_category_ID = -1, $level = 0)
{
    global $blog, $DB;
    $result_Array = array();
    $SQL = new SQL();
    $SQL->SELECT('cat_ID, cat_name');
    $SQL->FROM('T_categories');
    $SQL->WHERE('cat_blog_ID = ' . $DB->quote($blog));
    if ($parent_category_ID == -1) {
        $SQL->WHERE_and('cat_parent_ID IS NULL');
    } else {
        $SQL->WHERE('cat_parent_ID = ' . $DB->quote($parent_category_ID));
    }
    $SQL->ORDER_BY('cat_name');
    $categories = $DB->get_results($SQL->get());
    if (!empty($categories)) {
        foreach ($categories as $category) {
            $result_Array[] = array('value' => $category->cat_ID, 'label' => str_repeat('&nbsp;&nbsp;&nbsp;', $level) . $category->cat_name);
            $child_Categories_opts = fcpf_categories_select($category->cat_ID, $level + 1);
            if ($child_Categories_opts != '') {
                foreach ($child_Categories_opts as $cat) {
                    $result_Array[] = $cat;
                }
            }
        }
    }
    return $result_Array;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:35,代码来源:_file_create_posts.form.php

示例3: uninstall_b2evolution

/**
 * Uninstall b2evolution: Delete DB & Cache files
 */
function uninstall_b2evolution()
{
    global $DB;
    /* REMOVE PAGE CACHE */
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    // Remove general page cache
    $PageCache = new PageCache(NULL);
    $PageCache->cache_delete();
    // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
    if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
        // Get all blogs
        $blogs_SQL = new SQL();
        $blogs_SQL->SELECT('blog_ID');
        $blogs_SQL->FROM('T_blogs');
        $blogs = $DB->get_col($blogs_SQL->get());
        $BlogCache =& get_BlogCache('blog_ID');
        foreach ($blogs as $blog_ID) {
            $Blog = $BlogCache->get_by_ID($blog_ID);
            // Remove page cache of current blog
            $PageCache = new PageCache($Blog);
            $PageCache->cache_delete();
        }
    }
    /* REMOVE DATABASE */
    db_delete();
    echo '<p>' . T_('Reset done!') . '</p>';
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:30,代码来源:_functions_delete.php

示例4: get_newsletter_users_sql

/**
 * Get SQL for active users which accept newsletter email
 *
 * @param array users IDs
 * @return object SQL
 */
function get_newsletter_users_sql($users_IDs)
{
    global $Settings;
    $SQL = new SQL();
    $SQL->SELECT('u.user_ID');
    $SQL->FROM('T_users u');
    $SQL->FROM_add('LEFT OUTER JOIN T_users__usersettings us ON u.user_ID = us.uset_user_ID');
    $SQL->FROM_add('AND us.uset_name = \'newsletter_news\'');
    $SQL->WHERE('u.user_ID IN ( ' . implode(', ', $users_IDs) . ' )');
    $SQL->WHERE_and('u.user_status IN ( \'activated\', \'autoactivated\' )');
    if ($Settings->get('def_newsletter_news')) {
        // If General setting "newsletter_news" = 1 we also should include all users without defined user's setting "newsletter_news"
        $SQL->WHERE_and('( us.uset_value = 1 OR us.uset_value IS NULL )');
    } else {
        // If General setting "newsletter_news" = 0 we take only users which accept newsletter email
        $SQL->WHERE_and('us.uset_value = 1');
    }
    return $SQL;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:25,代码来源:_emailcampaign.funcs.php

示例5: load

 /**
  * Load permissions
  *
  * @param integer Group ID
  */
 function load($grp_ID)
 {
     global $DB, $modules;
     // Get default group permission from each module
     foreach ($modules as $module) {
         $Module =& $GLOBALS[$module . '_Module'];
         if (method_exists($Module, 'get_default_group_permissions')) {
             // Module has pluggable permissions and we can add them to the current setting
             $this->add($module, $Module->get_default_group_permissions($grp_ID), $grp_ID);
         }
     }
     if ($grp_ID != 0) {
         // Select current group permission from database
         $SQL = new SQL();
         $SQL->SELECT('*');
         $SQL->FROM('T_groups__groupsettings');
         $SQL->WHERE('gset_grp_ID = ' . $grp_ID);
         $DB->begin();
         // Set current group permissions
         $existing_perm = array();
         foreach ($DB->get_results($SQL->get()) as $row) {
             $existing_perm[] = $row->gset_name;
             $this->permission_values[$row->gset_name] = $row->gset_value;
         }
         // Set default group permission if these permissions don't exist
         $update_permissions = false;
         foreach ($this->permission_values as $name => $value) {
             if (!in_array($name, $existing_perm)) {
                 $this->set($name, $value, $grp_ID);
                 $update_permissions = true;
             }
         }
         if ($update_permissions) {
             // We can update permission as there are some new permnissions
             $this->dbupdate($grp_ID);
         }
         $DB->commit();
     }
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:44,代码来源:_groupsettings.class.php

示例6: param

 /**
  * Load data from Request form fields.
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_Request()
 {
     param_string_not_empty('dom_name', T_('Please enter domain name.'));
     $dom_name = get_param('dom_name');
     $this->set('name', $dom_name);
     $dom_status = param('dom_status', 'string', true);
     $this->set('status', $dom_status, true);
     $dom_type = param('dom_type', 'string', true);
     $this->set('type', $dom_type, true);
     if (!param_errors_detected()) {
         // Check domains with the same name and type
         global $Messages, $DB;
         $SQL = new SQL();
         $SQL->SELECT('dom_ID');
         $SQL->FROM('T_basedomains');
         $SQL->WHERE('dom_ID != ' . $this->ID);
         $SQL->WHERE_and('dom_name = ' . $DB->quote($dom_name));
         $SQL->WHERE_and('dom_type = ' . $DB->quote($dom_type));
         if ($DB->get_var($SQL->get())) {
             $Messages->add(T_('Domain already exists with the same name and type.'));
         }
     }
     return !param_errors_detected();
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:29,代码来源:_domain.class.php

示例7: die

    die('Please, do not access this page directly.');
}
global $dispatcher;
// Get params from request
$s = param('s', 'string', '', true);
// Search keyword
$c = param('c', 'integer', 0, true);
// Country
$r = param('r', 'integer', 0, true);
// Region
$sr = param('sr', 'integer', 0, true);
// Sub-region
// Create query
$SQL = new SQL();
$SQL->SELECT('city_ID, city_postcode, city_name, city_enabled, city_preferred, ctry_ID, ctry_name, rgn_ID, rgn_name, subrg_ID, subrg_name');
$SQL->FROM('T_regional__city');
$SQL->FROM_add('LEFT JOIN T_regional__country ON city_ctry_ID=ctry_ID');
$SQL->FROM_add('LEFT JOIN T_regional__region ON city_rgn_ID=rgn_ID');
$SQL->FROM_add('LEFT JOIN T_regional__subregion ON city_subrg_ID=subrg_ID');
$SQL->ORDER_BY('*, ctry_name, rgn_name, subrg_name');
$sql_where = array();
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $sql_where[] = 'CONCAT_WS( " ", city_postcode, city_name ) LIKE "%' . $DB->escape($s) . '%"';
}
if ($c > 0) {
    // Filter by country:
    $sql_where[] = 'ctry_ID = "' . $DB->escape($c) . '"';
}
if ($r > 0) {
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:_city_list.view.php

示例8: contacts_groups

function contacts_groups($user_ID)
{
    global $current_User, $DB, $cache_user_contacts_groups;
    if (!is_array($cache_user_contacts_groups)) {
        // Execute only first time to init cache
        $cache_user_contacts_groups = array();
        // Get contacts of current user
        $groups_SQL = new SQL();
        $groups_SQL->SELECT('cgr_ID AS ID, cgu_user_ID AS user_ID, cgr_name AS name');
        $groups_SQL->FROM('T_messaging__contact_groupusers');
        $groups_SQL->FROM_add('LEFT JOIN T_messaging__contact_groups ON cgu_cgr_ID = cgr_ID');
        $groups_SQL->WHERE('cgr_user_ID = ' . $current_User->ID);
        $groups_SQL->ORDER_BY('cgr_name');
        $groups = $DB->get_results($groups_SQL->get());
        $remove_link = url_add_param(get_dispctrl_url('contacts'), 'action=remove_user&amp;view=contacts&amp;' . url_crumb('messaging_contacts'));
        foreach ($groups as $group) {
            // Init cache for groups for each contact of current user
            $group_name = $group->name . action_icon(T_('Remove user from this group'), 'remove', url_add_param($remove_link, 'user_ID=' . $group->user_ID . '&amp;group_ID=' . $group->ID));
            if (isset($cache_user_contacts_groups[$group->user_ID])) {
                // nth group of this user
                $cache_user_contacts_groups[$group->user_ID] .= '<br />' . $group_name;
            } else {
                // first group of this user
                $cache_user_contacts_groups[$group->user_ID] = $group_name;
            }
        }
    }
    if (isset($cache_user_contacts_groups[$user_ID])) {
        // user has groups
        echo $cache_user_contacts_groups[$user_ID];
    }
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:32,代码来源:_contact_list.view.php

示例9: phpbb_subforums_list

/**
 * Display subforums to select what to import
 *
 * @param object Form
 * @param integer Category ID
 * @param integer Forum parent ID
 */
function phpbb_subforums_list(&$Form, $cat_id, $forum_parent_id = 0)
{
    global $phpbb_DB, $phpbb_subforums_list_level;
    // Get the forums from phpbb database
    $forums_SQL = new SQL();
    $forums_SQL->SELECT('f.forum_id, f.forum_name');
    $forums_SQL->FROM('BB_forums f');
    $forums_SQL->FROM_add('LEFT JOIN BB_categories c ON f.cat_id = c.cat_id');
    if ($cat_id > 0) {
        // Get all top forums of the category
        $forums_SQL->WHERE('f.cat_id = ' . $phpbb_DB->quote($cat_id));
        $forums_SQL->WHERE_AND('f.forum_parent = 0');
    } elseif ($forum_parent_id > 0) {
        // Get subforums
        $forums_SQL->WHERE('f.forum_parent = ' . $phpbb_DB->quote($forum_parent_id));
    } else {
        // Wrong a call of this function
        return;
    }
    $forums_SQL->ORDER_BY('c.cat_order, f.forum_order');
    $forums = $phpbb_DB->get_results($forums_SQL->get());
    if (count($forums) == 0) {
        return;
    }
    $phpbb_subforums_list_level++;
    // Group all subforums in one div
    echo '<div class="phpbb_forums_' . $cat_id . '_' . $forum_parent_id . '">';
    $import_forums = phpbb_get_var('import_forums');
    foreach ($forums as $forum) {
        // Display forums
        $Form->checkbox_input('phpbb_forums[]', !is_array($import_forums) || in_array($forum->forum_id, $import_forums), '', array('input_prefix' => '<label>', 'input_suffix' => ' ' . $forum->forum_name . '</label>', 'value' => $forum->forum_id, 'style' => 'margin-left:' . $phpbb_subforums_list_level * 20 . 'px'));
        phpbb_subforums_list($Form, 0, $forum->forum_id);
    }
    echo '</div>';
    $phpbb_subforums_list_level--;
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:43,代码来源:_phpbb.funcs.php

示例10: SQL

 /**
  * Get status
  *
  * @return string Status
  */
 function get_status()
 {
     global $DB;
     if ($this->ID > 0) {
         $SQL = new SQL('Get status of scheduled job');
         $SQL->SELECT('clog_status');
         $SQL->FROM('T_cron__log');
         $SQL->WHERE('clog_ctsk_ID = ' . $DB->quote($this->ID));
         $status = $DB->get_var($SQL->get());
     }
     if (empty($status)) {
         // Set default status for new cron jobs and for cron jobs without log
         $status = 'pending';
     }
     return $status;
 }
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:21,代码来源:_cronjob.class.php

示例11: ctry_td_enabled

 * @copyright (c)2009-2015 by Francois Planque - {@link http://fplanque.com/}
 * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
 *
 * @package evocore
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
load_class('regional/model/_currency.class.php', 'Currency');
load_funcs('regional/model/_regional.funcs.php');
// Get params from request
$s = param('s', 'string', '', true);
// Create query
$SQL = new SQL();
$SQL->SELECT('ctry_ID, ctry_code, ctry_name, curr_shortcut, curr_code, ctry_enabled, ctry_preferred, ctry_status, ctry_block_count');
$SQL->FROM('T_regional__country');
$SQL->FROM_add('LEFT JOIN T_regional__currency ON ctry_curr_ID=curr_ID');
$SQL->ORDER_BY('*, ctry_code ASC');
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $SQL->WHERE('CONCAT_WS( " ", ctry_code, ctry_name, curr_code ) LIKE "%' . $DB->escape($s) . '%"');
}
// Create result set:
$Results = new Results($SQL->get(), 'ctry_', '-D');
$Results->title = T_('Countries') . get_manual_link('regional-countries-tab');
/*
 * STATUS TD:
 */
function ctry_td_enabled($ctry_enabled, $ctry_ID)
{
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:_country_list.view.php

示例12: param

$Form->hidden('blog', $edited_Blog->ID);
$Form->begin_fieldset(T_('User permissions') . get_manual_link('user_permissions'));
/*
 * Query user list:
 */
if (get_param('action') == 'filter2') {
    $keywords = param('keywords2', 'string', '', true);
    set_param('keywords1', $keywords);
} else {
    $keywords = param('keywords1', 'string', '', true);
    set_param('keywords2', $keywords);
}
$SQL = new SQL();
$SQL->SELECT('user_ID, user_login, user_level, bloguser_perm_poststatuses + 0 as perm_poststatuses, bloguser_perm_edit, bloguser_ismember,' . 'bloguser_perm_delcmts, bloguser_perm_recycle_owncmts, bloguser_perm_vote_spam_cmts, bloguser_perm_cmtstatuses + 0 as perm_cmtstatuses, bloguser_perm_edit_cmt,' . 'bloguser_perm_delpost, bloguser_perm_edit_ts, bloguser_perm_cats,' . 'bloguser_perm_properties, bloguser_perm_admin, bloguser_perm_media_upload,' . 'bloguser_perm_media_browse, bloguser_perm_media_change, bloguser_perm_page,' . 'bloguser_perm_intro, bloguser_perm_podcast, bloguser_perm_sidebar');
$SQL->FROM('T_users LEFT JOIN T_coll_user_perms ON (
				 						user_ID = bloguser_user_ID
										AND bloguser_blog_ID = ' . $edited_Blog->ID . ' )');
$SQL->ORDER_BY('bloguser_ismember DESC, *, user_login, user_ID');
if (!empty($keywords)) {
    $SQL->add_search_field('user_login');
    $SQL->add_search_field('user_firstname');
    $SQL->add_search_field('user_lastname');
    $SQL->add_search_field('user_nickname');
    $SQL->add_search_field('user_email');
    $SQL->WHERE_keywords($keywords, 'AND');
}
// Display wide layout:
?>

<div id="userlist_wide" class="clear">
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:30,代码来源:_coll_user_perm.form.php

示例13: array

 /**
  * Get the custom feilds
  *
  * @param string Type of custom field: 'all', 'varchar', 'double'
  * @param string Field name that is used as key of array: 'ID', 'ityp_ID', 'label', 'name', 'type', 'order'
  * @return array Custom fields
  */
 function get_custom_fields($type = 'all', $array_key = 'name')
 {
     if (!isset($this->custom_fields)) {
         // Initialize an array only first time
         if (empty($this->ID)) {
             // Set an empty array for new creating post type
             $this->custom_fields = array();
         } else {
             // Get the custom fields from DB
             global $DB;
             $SQL = new SQL();
             $SQL->SELECT('itcf_ID AS ID, itcf_ityp_ID AS ityp_ID, itcf_label AS label, itcf_name AS name, itcf_type AS type, itcf_order AS `order`');
             $SQL->FROM('T_items__type_custom_field');
             $SQL->WHERE('itcf_ityp_ID = ' . $DB->quote($this->ID));
             $SQL->ORDER_BY('itcf_order, itcf_ID');
             $this->custom_fields = $DB->get_results($SQL->get(), ARRAY_A);
         }
     }
     $custom_fields = array();
     foreach ($this->custom_fields as $custom_field) {
         if ($type == 'all' || $type == $custom_field['type']) {
             switch ($array_key) {
                 case 'name':
                     // Use field 'name' as key of array
                     if (empty($custom_field['name'])) {
                         // Name can be empty when we are saving it with empty name and page is displayed with error messages
                         $field_index = $custom_field['ID'];
                     } else {
                         // Get field index from name
                         $field_index = preg_replace('/\\s+/', '_', strtolower(trim($custom_field['name'])));
                     }
                     break;
                 default:
                     // Set an array key from other field, or use 'ID' on invalid field name
                     $field_index = isset($custom_field[$array_key]) ? $custom_field[$array_key] : $custom_field['ID'];
                     break;
             }
             $custom_fields[$field_index] = $custom_field;
         }
     }
     return $custom_fields;
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:49,代码来源:_itemtype.class.php

示例14: trim

}
if (param_date('datestopinput', T_('Invalid date'), false, NULL) !== NULL) {
    // We have a user provided localized date:
    memorize_param('datestop', 'string', NULL, trim(form_date($datestopinput)));
} else {
    // We may have an automated param transmission date:
    param('datestop', 'string', '', true);
}
param('email', 'string', '', true);
// Create result set:
$SQL = new SQL();
$SQL->SELECT('SQL_NO_CACHE emlog_ID, emlog_timestamp, emlog_user_ID, emlog_to, emlog_result, emlog_subject');
$SQL->FROM('T_email__log');
$CountSQL = new SQL();
$CountSQL->SELECT('SQL_NO_CACHE COUNT(emlog_ID)');
$CountSQL->FROM('T_email__log');
if (!empty($datestart)) {
    // Filter by start date
    $SQL->WHERE_and('emlog_timestamp >= ' . $DB->quote($datestart . ' 00:00:00'));
    $CountSQL->WHERE_and('emlog_timestamp >= ' . $DB->quote($datestart . ' 00:00:00'));
}
if (!empty($datestop)) {
    // Filter by end date
    $SQL->WHERE_and('emlog_timestamp <= ' . $DB->quote($datestop . ' 23:59:59'));
    $CountSQL->WHERE_and('emlog_timestamp <= ' . $DB->quote($datestop . ' 23:59:59'));
}
if (!empty($email)) {
    // Filter by email
    $SQL->WHERE_and('emlog_to LIKE ' . $DB->quote($email));
    $CountSQL->WHERE_and('emlog_to LIKE ' . $DB->quote($email));
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:31,代码来源:_email_sent.view.php

示例15: upgrade_b2evo_tables

/**
 * upgrade_b2evo_tables(-)
 *
 * @param string the action param value corresponding the current upgrade process ( evoupgrade, svn_upgrade, auto_upgrade )
 */
function upgrade_b2evo_tables($upgrade_action = 'evoupgrade')
{
    global $db_config, $tableprefix;
    global $baseurl, $old_db_version, $new_db_version;
    global $Group_Admins, $Group_Privileged, $Group_Bloggers, $Group_Users;
    global $locales, $locale;
    global $DB;
    global $admin_url;
    global $Settings, $Plugins;
    // used for defaults, when upgrading to 1.6
    global $use_fileupload, $fileupload_allowedtypes, $fileupload_maxk, $doubleCheckReferers;
    // new DB-delta functionality
    global $schema_queries, $inc_path;
    // used to check script time before starting to create db delta
    global $script_start_time;
    // Create an option which can be turned on if we need to regenerate the autogenerated excerpts in the end of the upgrade script
    global $recreate_autogenerated_excerpts;
    $recreate_autogenerated_excerpts = param('recreate_excerpts', 'boolean', 0);
    // Load DB schema from modules
    load_db_schema();
    // Update the progress bar status
    update_install_progress_bar();
    load_funcs('_core/model/db/_upgrade.funcs.php');
    // Force MySQL strict mode:
    $DB->query('SET sql_mode = ""', 'REMOVE MySQL "strict" mode in order not to worry about missing defaults until the end of the upgrade.');
    echo '<p>' . T_('Checking DB schema version...') . ' ';
    $old_db_version = get_db_version();
    if (empty($old_db_version)) {
        echo '<p><strong>OOPS! b2evolution doesn\'t seem to be installed yet.</strong></p>';
        return false;
    }
    echo $old_db_version, ' : ';
    if ($old_db_version < 8000) {
        debug_die(T_('This version is too old!'));
    }
    if ($old_db_version > $new_db_version) {
        debug_die(T_('This version is too recent! We cannot downgrade to the version you are trying to install...'));
    }
    echo "OK.<br />\n";
    if ($old_db_version < 8010) {
        echo 'Upgrading users table... ';
        $query = "ALTER TABLE T_users\n\t\t\t\t\t\t\tMODIFY COLUMN user_pass CHAR(32) NOT NULL";
        $DB->query($query);
        echo "OK.<br />\n";
        echo 'Upgrading blogs table... ';
        $query = "ALTER TABLE T_blogs\n\t\t\t\t\t\t\tMODIFY COLUMN blog_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',\n\t\t\t\t\t\t\tMODIFY COLUMN blog_longdesc TEXT NULL DEFAULT NULL";
        $DB->query($query);
        echo "OK.<br />\n";
        echo 'Upgrading categories table... ';
        $query = "ALTER TABLE T_categories\n\t\t\t\t\t\t\tADD COLUMN cat_description VARCHAR(250) NULL DEFAULT NULL,\n\t\t\t\t\t\t\tADD COLUMN cat_longdesc TEXT NULL DEFAULT NULL,\n\t\t\t\t\t\t\tADD COLUMN cat_icon VARCHAR(30) NULL DEFAULT NULL";
        $DB->query($query);
        echo "OK.<br />\n";
        echo 'Upgrading posts table... ';
        $query = "ALTER TABLE {$tableprefix}posts\n\t\t\t\t\t\t\tMODIFY COLUMN post_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',\n\t\t\t\t\t\t\tADD COLUMN post_urltitle VARCHAR(50) NULL DEFAULT NULL AFTER post_title,\n\t\t\t\t\t\t\tADD COLUMN post_url VARCHAR(250) NULL DEFAULT NULL AFTER post_urltitle,\n\t\t\t\t\t\t\tADD COLUMN post_comments ENUM('disabled', 'open', 'closed') NOT NULL DEFAULT 'open' AFTER post_wordcount";
        $DB->query($query);
        echo "OK.<br />\n";
        echo 'Generating wordcounts... ';
        load_funcs('items/model/_item.funcs.php');
        $query = "SELECT ID, post_content FROM {$tableprefix}posts WHERE post_wordcount IS NULL";
        $i = 0;
        foreach ($DB->get_results($query, ARRAY_A) as $row) {
            $query_update_wordcount = "UPDATE {$tableprefix}posts\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSET post_wordcount = " . bpost_count_words($row['post_content']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE ID = " . $row['ID'];
            $DB->query($query_update_wordcount);
            $i++;
        }
        echo "OK. ({$i} rows updated)<br />\n";
        set_upgrade_checkpoint('8010');
    }
    if ($old_db_version < 8020) {
        echo 'Encoding passwords... ';
        $query = "UPDATE T_users\n\t\t\t\t\t\t\tSET user_pass = MD5(user_pass)";
        $DB->query($query);
        echo "OK.<br />\n";
        set_upgrade_checkpoint('8020');
    }
    if ($old_db_version < 8030) {
        echo 'Deleting unecessary logs... ';
        $query = "DELETE FROM T_hitlog\n\t\t\t\t\t\t\tWHERE hit_ignore = 'badchar'";
        $DB->query($query);
        echo "OK.<br />\n";
        echo 'Updating blog urls... ';
        $query = "SELECT blog_ID, blog_siteurl FROM T_blogs";
        $i = 0;
        foreach ($DB->get_results($query, ARRAY_A) as $row) {
            $blog_ID = $row['blog_ID'];
            $blog_siteurl = $row['blog_siteurl'];
            // echo $blog_ID.':'.$blog_siteurl;
            if (strpos($blog_siteurl . '/', $baseurl) !== 0) {
                // If not found at position 0
                echo ' <strong>WARNING: please check blog #', $blog_ID, ' manually.</strong><br /> ';
                continue;
            }
            // crop off the baseurl:
            $blog_siteurl = utf8_substr($blog_siteurl . '/', utf8_strlen($baseurl));
            // echo ' -> ', $blog_siteurl,'<br />';
//.........这里部分代码省略.........
开发者ID:Edind304,项目名称:b2evolution,代码行数:101,代码来源:_functions_evoupgrade.php


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