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


PHP DBUtil::dropColumn方法代码示例

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


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

示例1: mediashare_upgrade_to_2_2_0

function mediashare_upgrade_to_2_2_0()
{
    $columns = array_keys(DBUtil::metaColumns('mediashare_mediastore', true));
    if (in_array('MSS_DATA', $columns) && !DBUtil::dropColumn('mediashare_mediastore', 'mss_data')) {
        return false;
    }
    if (!mediashareCreateMediaDB()) {
        return false;
    }
    return true;
}
开发者ID:ro0f,项目名称:Mediashare,代码行数:11,代码来源:pninit.php

示例2: _migratecategories

    /**
     * migrate old local categories to the categories module
     */
    private function _migratecategories()
    {
        // load the admin language file
        // pull all data from the old table
        $prefix = System::getVar('prefix');
        $sql    = "SELECT pn_secname, pn_image, pn_secid FROM {$prefix}_sections";
        $result = DBUtil::executeSQL($sql);
        $categories = array();
        for (; !$result->EOF; $result->MoveNext()) {
            $categories[] = $result->fields;
        }

        // get the language file
        $lang = ZLanguage::getLanguageCode();

        // create root category and entry in the categories registry
        $this->_createdefaultcategory('/__SYSTEM__/Modules/Pages');

        // get the category path for which we're going to insert our upgraded categories
        $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Pages');

        // migrate our categories
        $categorymap = array();
        foreach ($categories as $category) {
            $cat = new Categories_DBObject_Category ();
            $cat->setDataField('parent_id', $rootcat['id']);
            $cat->setDataField('name', $category[0]);
            $cat->setDataField('display_name', array($lang => $category[0]));
            $cat->setDataField('display_desc', array($lang => $category[0]));
            $cat->setDataField('data1', $category[1]);
            if (!$cat->validate('admin')) {
                return false;
            }
            $cat->insert();
            $cat->update();
            $categorymap[$category[2]] = $cat->getDataField('id');
        }

        // migrate page category assignments
        $sql = "SELECT pn_pageid, pn_secid FROM {$prefix}_pages";
        $result = DBUtil::executeSQL($sql);
        $pages = array();
        for (; !$result->EOF; $result->MoveNext()) {
            $pages[] = array('pageid' => $result->fields[0],
                    '__CATEGORIES__' => array('Main' => $categorymap[$result->fields[1]]),
                    '__META__' => array('module' => 'Pages'));
        }

        foreach ($pages as $page) {
            if (!DBUtil::updateObject($page, 'pages', '', 'pageid')) {
                return LogUtil::registerError($this->__('Error! Update attempt failed.'));
            }
        }

        // drop old table
        DBUtil::dropTable('sections');

        // finally drop the secid column
        DBUtil::dropColumn('pages', 'pn_secid');

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:65,代码来源:Installer.php

示例3: upgrade113XTablesTo220Tables


//.........这里部分代码省略.........
        $obaColumn = $dbinfoSystem['objectdata_attributes_column'];

        $limitNumRows = 100;
        $limitOffset = 0;
        $updated = true;
        $userCount = DBUtil::selectObjectCount('users_temp');
        // Pass through the users_temp table in chunks of 100
        //  * ensure unames and email addresses are lower case,
        while ($limitOffset < $userCount) {
            $userTempArray = DBUtil::selectObjectArray('users_temp', '', '', $limitOffset, $limitNumRows, '', null, null,
                array('tid', 'type', 'uname', 'email', 'pass', 'hash_method', 'dynamics', 'comment'));
            $userArray = array();
            if (!empty($userTempArray) && is_array($userTempArray)) {
                foreach ($userTempArray as $key => $userTempOpj) {
                    // type == 1: User registration pending approval (moderation)
                    if ($userTempArray[$key]['type'] == 1) {
                        $userObj = array();

                        // Ensure uname and email are lower case
                        $userObj['uname'] = mb_strtolower($userTempArray[$key]['uname']);
                        $userObj['email'] = mb_strtolower($userTempArray[$key]['email']);

                        // Convert pass to salted pass with embedded hash method, leave salt blank
                        $userObj['pass'] = $userTempArray[$key]['hash_method'] . '$$' . $userTempArray[$key]['pass'];

                        $userObj['approved_by'] = 0;
                        $userObj['activated'] = Users_Constant::ACTIVATED_PENDING_REG;

                        if (!empty($userTempArray[$key]['dynamics'])) {
                            $userObj['__ATTRIBUTES__'] = unserialize($userTempArray[$key]['dynamics']);
                        } else {
                            $userObj['__ATTRIBUTES__'] = array();
                        }

                        if (isset($userObj['dynamics']) && !empty($userObj['dynamics'])) {
                            if (DataUtil::is_serialized($userObj['dynamics'])) {
                                $dynamics = @unserialize($userObj['dynamics']);
                                if (!empty($dynamics) && is_array($dynamics)) {
                                    foreach ($dynamics as $key => $value) {
                                        $userObj['__ATTRIBUTES__'][$key] = $value;
                                    }
                                }
                            }
                        }

                        $userObj['__ATTRIBUTES__']['_Users_isVerified'] = 0;

                        if ($legalModuleActive) {
                            $userRegDateTime = new DateTime($userArray[$key]['user_regdate'], new DateTimeZone('UTC'));
                            $policyDateTimeStr = $userRegDateTime->format(DATE_ISO8601);

                            if ($termsOfUseActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_termsOfUseAccepted'] = $policyDateTimeStr;
                            }
                            if ($privacyPolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_privacyPolicyAccepted'] = $policyDateTimeStr;
                            }
                            if ($agePolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_agePolicyConfirmed'] = $policyDateTimeStr;
                            }
                        }

                        $userArray[] = $userObj;
                    } else {
                        throw new Zikula_Exception_Fatal($this->__f('Unknown users_temp record type: %1$s', array($userTempArray[$key]['type'])));
                    }
                }
            }
            if (!DBUtil::insertObjectArray($userArray, 'users', 'uid', false)) {
                $updated = false;
                break;
            }
            $limitOffset += $limitNumRows;
        }
        if (!$updated) {
            return false;
        }

        // Done upgrading. Let's lose some old fields and tables we no longer need.
        DBUtil::dropColumn('users', $usersOldFieldsDB);
        DBUtil::dropTable('users_temp');

        // Reset the system tables to the new table definitons, so the rest of the
        // system upgrade goes smoothly.
        $dbinfoSystem = $serviceManager['dbtables'];
        foreach ($dbinfo113X as $key => $value) {
            unset($dbinfoSystem[$key]);
        }
        foreach ($dbinfo220 as $key => $value) {
            $dbinfoSystem[$key] = $value;
        }
        $serviceManager['dbtables'] = $dbinfoSystem;

        // Update users table for data type change of activated field.
        if (!DBUtil::changeTable('users')) {
            return false;
        }

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Installer.php

示例4: _news_migratecategories

    /**
     * migrate old local categories to the categories module
     */
    private function _news_migratecategories()
    {
        // load the admin language file
        // pull all data from the old tables
        $tables = DBUtil::getTables();
        $columns = $tables['news_column'];
        $sql = "SELECT $columns[catid], $columns[title] FROM {$tables[stories_cat]}";
        $result = DBUtil::executeSQL($sql);
        $categories = array(array(0, 'Articles'));
        for (; !$result->EOF; $result->MoveNext()) {
            $categories[] = $result->fields;
        }
        $sql = "SELECT $columns[topicid], $columns[topicname], $columns[topicimage], $columns[topictext] FROM {$tables[topics]}";
        $result = DBUtil::executeSQL($sql);
        $topics = array();
        for (; !$result->EOF; $result->MoveNext()) {
            $topics[] = $result->fields;
        }

        // get the language file
        $lang = ZLanguage::getLanguageCode();

        // create the Main category and entry in the categories registry
        $this->_createdefaultcategory('/__SYSTEM__/Modules/News');

        // create the Topics category and entry in the categories registry
        $this->_createtopicscategory('/__SYSTEM__/Modules/Topics');

        // get the category path for which we're going to insert our upgraded News categories
        $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/News');

        // migrate our main categories
        $categorymap = array();
        foreach ($categories as $category) {
            $cat = new Categories_DBObject_Category();
            $cat->setDataField('parent_id', $rootcat['id']);
            $cat->setDataField('name', $category[1]);
            $cat->setDataField('display_name', array($lang => $category[1]));
            $cat->setDataField('display_desc', array($lang => $category[1]));
            if (!$cat->validate('admin')) {
                return false;
            }
            $cat->insert();
            $cat->update();
            $categorymap[$category[0]] = $cat->getDataField('id');
        }

        // get the category path for which we're going to insert our upgraded Topics categories
        $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Topics');

        // migrate our topic categories
        $topicsmap = array();
        foreach ($topics as $topic) {
            $cat = new Categories_DBObject_Category();
            $data = $cat->getData();
            $data['parent_id']                     = $rootcat['id'];
            $data['name']                          = $topic[1];
            $data['value']                         = -1;
            $data['display_name']                  = array($lang => $topic[3]);
            $data['display_desc']                  = array($lang => $topic[3]);
            $data['__ATTRIBUTES__']['topic_image'] = $topic[2];
            $cat->setData ($data);
            if (!$cat->validate('admin')) {
                return false;
            }
            $cat->insert();
            $cat->update();
            $topicsmap[$topic[0]] = $cat->getDataField('id');
        }

        // After an upgrade we want the legacy topic template variables to point to the Topic property
        $this->setVar('topicproperty', 'Topic');

        // migrate page category assignments
        $sql = "SELECT $columns[sid], $columns[catid], $columns[topic] FROM {$tables[stories]}";
        $result = DBUtil::executeSQL($sql);
        $pages = array();
        for (; !$result->EOF; $result->MoveNext()) {
            $pages[] = array('sid' => $result->fields[0],
                    '__CATEGORIES__' => array(
                        'Main' => $categorymap[$result->fields[1]],
                        'Topic' => $topicsmap[$result->fields[2]]),
                    '__META__' => array('module' => 'News'));
        }
        foreach ($pages as $page) {
            if (!DBUtil::updateObject($page, 'stories', '', 'sid')) {
                return LogUtil::registerError($this->__('Error! Could not update the article categories.'));
            }
        }

        // drop old table
        DBUtil::dropTable('stories_cat');
        // we don't drop the topics table - this is the job of the topics module

        // finally drop the secid column
        DBUtil::dropColumn('stories', $columns['catid']);
        DBUtil::dropColumn('stories', $columns['topic']);
//.........这里部分代码省略.........
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Installer.php


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