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


PHP qa_db_add_table_prefix函数代码示例

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


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

示例1: init_queries

    function init_queries($tableslc)
    {
        $tbl1 = qa_db_add_table_prefix('chat_posts');
        $tbl2 = qa_db_add_table_prefix('chat_users');
        if (in_array($tbl1, $tableslc) && in_array($tbl2, $tableslc)) {
            qa_opt($this->optactive, '1');
            return null;
        }
        return array('CREATE TABLE IF NOT EXISTS ^chat_posts (
			  `postid` int(10) unsigned NOT NULL AUTO_INCREMENT,
			  `userid` int(10) unsigned NOT NULL,
			  `posted` datetime NOT NULL,
			  `message` varchar(800) NOT NULL,
			  PRIMARY KEY (`postid`),
			  KEY `posted` (`posted`)
			) ENGINE=InnoDB  DEFAULT CHARSET=utf8', 'CREATE TABLE IF NOT EXISTS ^chat_users (
			  `userid` int(10) unsigned NOT NULL,
			  `lastposted` datetime NOT NULL,
			  `lastpolled` datetime NOT NULL,
			  `kickeduntil` datetime NOT NULL DEFAULT "2012-01-01 00:00:00",
			  PRIMARY KEY (`userid`),
			  KEY `active` (`lastpolled`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8', 'CREATE TABLE IF NOT EXISTS ^chat_kicks (
			  `userid` int(10) unsigned NOT NULL,
			  `kickedby` int(10) unsigned NOT NULL,
			  `whenkicked` datetime NOT NULL,
			  PRIMARY KEY (`userid`,`kickedby`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8');
    }
开发者ID:microbye,项目名称:q2a-chat-room,代码行数:29,代码来源:qa-chat.php

示例2: init_queries

 function init_queries($tableslc)
 {
     $tbl1 = qa_db_add_table_prefix('homepage');
     if (in_array($tbl1, $tableslc)) {
         return null;
     }
     return "CREATE TABLE IF NOT EXISTS ^homepage (\n\t\t\t\t\t\t`questionid` int(10) unsigned NOT NULL,\n\t\t\t\t\t\t`childid` int(10) unsigned,\n\t\t\t\t\t\t`updated` datetime NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (questionid)\n\t\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8";
 }
开发者ID:BrunoVandekerkhove,项目名称:q2a-expandable-question-lists,代码行数:8,代码来源:qa-eql-admin.php

示例3: init_queries

 function init_queries($tableslc)
 {
     $tablename = qa_db_add_table_prefix($this->pluginkey);
     if (!in_array($tablename, $tableslc)) {
         return 'CREATE TABLE IF NOT EXISTS ^' . $this->pluginkey . ' ( ' . '`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, ' . '`title` varchar(30) NOT NULL, ' . '`pages` varchar(800) NOT NULL, ' . '`position` varchar(30) NOT NULL, ' . '`ordering` smallint(5) unsigned NOT NULL, ' . '`content` text NOT NULL, ' . 'PRIMARY KEY (`id`), ' . 'KEY `position` (`position`,`ordering`) ' . ' ) ENGINE=InnoDB DEFAULT CHARSET=utf8';
     }
     // we're already set up
     qa_opt($this->opt, '1');
     return null;
 }
开发者ID:siddiquinoor,项目名称:q2a-widget-anywhere,代码行数:10,代码来源:qa-widget-anywhere.php

示例4: init_queries

 public function init_queries($table_list)
 {
     if (qa_opt('event_logger_to_database')) {
         $tablename = qa_db_add_table_prefix('eventlog');
         if (!in_array($tablename, $table_list)) {
             require_once QA_INCLUDE_DIR . 'app/users.php';
             require_once QA_INCLUDE_DIR . 'db/maxima.php';
             return 'CREATE TABLE ^eventlog (' . 'datetime DATETIME NOT NULL,' . 'ipaddress VARCHAR (15) CHARACTER SET ascii,' . 'userid ' . qa_get_mysql_user_column_type() . ',' . 'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' . 'cookieid BIGINT UNSIGNED,' . 'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' . 'params VARCHAR (800) NOT NULL,' . 'KEY datetime (datetime),' . 'KEY ipaddress (ipaddress),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
         }
     }
 }
开发者ID:swuit,项目名称:swuit-q2a,代码行数:11,代码来源:qa-event-logger.php

示例5: init_queries

 function init_queries($tableslc)
 {
     //qw_check_for_new_version(false);
     include_once QA_INCLUDE_DIR . 'qa-app-users.php';
     //if(qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN){
     $queries = array();
     $queries = qw_apply_filter('init_queries', $queries, $tableslc);
     $tablename = qa_db_add_table_prefix('ra_userevent');
     if (!in_array($tablename, $tableslc)) {
         require_once QA_INCLUDE_DIR . 'qa-app-users.php';
         require_once QA_INCLUDE_DIR . 'qa-db-maxima.php';
         $queries[] = 'CREATE TABLE ^ra_userevent (' . 'id bigint(20) NOT NULL AUTO_INCREMENT,' . 'datetime DATETIME NOT NULL,' . 'userid ' . qa_get_mysql_user_column_type() . ',' . 'postid int(10) unsigned DEFAULT NULL,' . 'effecteduserid ' . qa_get_mysql_user_column_type() . ' unsigned DEFAULT NULL,' . 'event VARCHAR (20) CHARACTER SET utf8 NOT NULL,' . 'params text NOT NULL,' . '`read` tinyint(1) NOT NULL DEFAULT "0",' . 'PRIMARY KEY (id),' . 'KEY datetime (datetime),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
     }
     return $queries;
     ///}
 }
开发者ID:rahularyan,项目名称:dude-theme,代码行数:16,代码来源:init.php

示例6: init_queries

 function init_queries($tableslc)
 {
     require_once QA_INCLUDE_DIR . 'qa-app-users.php';
     require_once QA_INCLUDE_DIR . 'qa-db-maxima.php';
     qa_opt('event_logger_to_database', 1);
     /* remove evnet logger plugin if exist */
     if (file_exists(QA_INCLUDE_DIR . 'qa-plugin/event-logger')) {
         unlink(QA_INCLUDE_DIR . 'qa-plugin/event-logger');
     }
     $tablename = qa_db_add_table_prefix('eventlog');
     $quries = array();
     if (!in_array($tablename, $tableslc)) {
         require_once QA_INCLUDE_DIR . 'qa-app-users.php';
         require_once QA_INCLUDE_DIR . 'qa-db-maxima.php';
         $quries[] = 'CREATE TABLE ^eventlog (' . 'datetime DATETIME NOT NULL,' . 'ipaddress VARCHAR (15) CHARACTER SET ascii,' . 'userid INT(10),' . 'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' . 'cookieid BIGINT UNSIGNED,' . 'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' . 'params LONGTEXT NOT NULL,' . 'KEY datetime (datetime),' . 'KEY ipaddress (ipaddress),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
     }
     if (in_array($tablename, $tableslc) && !qa_opt('qw_eventlog_param_datatype')) {
         qa_opt('qw_eventlog_param_datatype', 1);
         $quries[] = 'ALTER TABLE ^eventlog MODIFY params LONGTEXT;';
     }
     return $quries;
 }
开发者ID:rahularyan,项目名称:dude-theme,代码行数:22,代码来源:cs-event-logger.php

示例7: init_queries

    function init_queries($tableslc)
    {
        $tablename = qa_db_add_table_prefix('eventlog');
        // check if event logger has been initialized already (check for one of the options and existing table)
        require_once QA_INCLUDE_DIR . 'qa-app-options.php';
        if (qa_opt('event_logger_to_database') && in_array($tablename, $tableslc)) {
            // options exist, but check if really enabled
            if (qa_opt('event_logger_to_database') == '' && qa_opt('event_logger_to_files') == '') {
                // enabled database logging
                qa_opt('event_logger_to_database', 1);
            }
        } else {
            // not enabled, let's enable the event logger
            // set option values for event logger
            qa_opt('event_logger_to_database', 1);
            qa_opt('event_logger_to_files', '');
            qa_opt('event_logger_directory', '');
            qa_opt('event_logger_hide_header', '');
            if (!in_array($tablename, $tableslc)) {
                require_once QA_INCLUDE_DIR . 'qa-app-users.php';
                require_once QA_INCLUDE_DIR . 'qa-db-maxima.php';
                return 'CREATE TABLE IF NOT EXISTS ^eventlog (' . 'datetime DATETIME NOT NULL,' . 'ipaddress VARCHAR (15) CHARACTER SET ascii,' . 'userid ' . qa_get_mysql_user_column_type() . ',' . 'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' . 'cookieid BIGINT UNSIGNED,' . 'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' . 'params VARCHAR (800) NOT NULL,' . 'KEY datetime (datetime),' . 'KEY ipaddress (ipaddress),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
            }
        }
        // memo: would be best to check if plugin is installed in qa-plugin folder or using plugin_exists()
        // however this functionality is not available in q2a v1.6.3
        // create table qa_usermeta which stores the last visit of each user
        $tablename2 = qa_db_add_table_prefix('usermeta');
        if (!in_array($tablename2, $tableslc)) {
            qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usermeta (
					meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
					user_id bigint(20) unsigned NOT NULL,
					meta_key varchar(255) DEFAULT NULL,
					meta_value longtext,
					PRIMARY KEY (meta_id),
					UNIQUE (user_id,meta_key)
					) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
        }
    }
开发者ID:Kasparohub,项目名称:q2apro-on-site-notifications,代码行数:39,代码来源:q2apro-onsitenotifications-admin.php

示例8: init_queries

    function init_queries($tableslc)
    {
        $queries = array();
        if (!in_array(qa_db_add_table_prefix('caching'), $tableslc)) {
            $queries[] = 'CREATE TABLE IF NOT EXISTS `^caching` (
`sign` TINYINT UNSIGNED DEFAULT NULL,
`format` CHAR(8) DEFAULT NULL,
`type` CHAR(8) DEFAULT NULL,
`device` CHAR(8) DEFAULT NULL,
`filename` VARCHAR(255) DEFAULT NULL,
`content` MEDIUMBLOB NOT NULL,
`userid` INT(10) UNSIGNED DEFAULT NULL,
`cookieid` BIGINT(20) UNSIGNED DEFAULT NULL,
`createip` INT(10) UNSIGNED DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`sign`, `format`, `type`, `device`, `filename`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
        }
        if (count($queries)) {
            return $queries;
        } else {
            return null;
        }
    }
开发者ID:amiyasahu,项目名称:q2a-caching,代码行数:24,代码来源:qa-caching-admin.php

示例9: init_queries

    function init_queries($tableslc)
    {
        $tbl1 = qa_db_add_table_prefix('blog_posts');
        $tbl2 = qa_db_add_table_prefix('blog_comments');
        if (in_array($tbl1, $tableslc) && in_array($tbl2, $tableslc)) {
            return null;
        }
        return array('CREATE TABLE IF NOT EXISTS ^blog_posts (
			  `postid` int(10) unsigned NOT NULL AUTO_INCREMENT,
			  `userid` int(10) unsigned NOT NULL,
			  `title` varchar(300),
			  `type` int(10) unsigned,
			  `content` text,
			  `posted` datetime,
			  `views` int(10) unsigned,
			  `updated` datetime,
			  `tags` varchar(300) NOT NULL,
			  `notify` varchar(300) NOT NULL,
			  `format` varchar(100) NOT NULL,
			  PRIMARY KEY (`postid`),
			  KEY `posted` (`posted`),
			  KEY `updated` (`updated`)
			) ENGINE=InnoDB  DEFAULT CHARSET=utf8', 'CREATE TABLE IF NOT EXISTS ^blog_comments (
			  `postid` int(10) unsigned NOT NULL AUTO_INCREMENT,
			  `parentid` int(10) unsigned NOT NULL,
			  `posted` datetime NOT NULL,
			  `comment` text NOT NULL,
			  `userid` int(10) unsigned NOT NULL,
			  `updated` datetime,
			  `format` varchar(100) NOT NULL,
			  PRIMARY KEY (`postid`),
			  KEY `parentid` (`parentid`),
			  KEY `posted` (`posted`),
			  KEY `updated` (`updated`)
			 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8');
    }
开发者ID:arjunsuresh,项目名称:qa-blog-post,代码行数:36,代码来源:qa-articles.php

示例10: qa_db_upgrade_tables

function qa_db_upgrade_tables()
{
    require_once QA_INCLUDE_DIR . 'app/recalc.php';
    $definitions = qa_db_table_definitions();
    $keyrecalc = array();
    //	Write-lock all Q2A tables before we start so no one can read or write anything
    $keydbtables = qa_array_to_keys(qa_db_list_tables());
    foreach ($definitions as $rawname => $definition) {
        if (isset($keydbtables[qa_db_add_table_prefix($rawname)])) {
            $locks[] = '^' . $rawname . ' WRITE';
        }
    }
    $locktablesquery = 'LOCK TABLES ' . implode(', ', $locks);
    qa_db_upgrade_query($locktablesquery);
    //	Upgrade it step-by-step until it's up to date (do LOCK TABLES after ALTER TABLE because the lock can sometimes be lost)
    while (1) {
        $version = qa_db_get_db_version();
        if ($version >= QA_DB_VERSION_CURRENT) {
            break;
        }
        $newversion = $version + 1;
        qa_db_upgrade_progress(QA_DB_VERSION_CURRENT - $version . ' upgrade step/s remaining...');
        switch ($newversion) {
            //	Up to here: Version 1.0 beta 1
            case 2:
                qa_db_upgrade_query('ALTER TABLE ^posts DROP COLUMN votes, ADD COLUMN upvotes ' . $definitions['posts']['upvotes'] . ' AFTER cookieid, ADD COLUMN downvotes ' . $definitions['posts']['downvotes'] . ' AFTER upvotes');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecountposts'] = true;
                break;
            case 3:
                qa_db_upgrade_query('ALTER TABLE ^userpoints ADD COLUMN upvoteds ' . $definitions['userpoints']['upvoteds'] . ' AFTER avoteds, ADD COLUMN downvoteds ' . $definitions['userpoints']['downvoteds'] . ' AFTER upvoteds');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
            case 4:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN lastuserid ' . $definitions['posts']['lastuserid'] . ' AFTER cookieid, CHANGE COLUMN updated updated ' . $definitions['posts']['updated']);
                qa_db_upgrade_query($locktablesquery);
                qa_db_upgrade_query('UPDATE ^posts SET updated=NULL WHERE updated=0 OR updated=created');
                break;
            case 5:
                qa_db_upgrade_query('ALTER TABLE ^contentwords ADD COLUMN type ' . $definitions['contentwords']['type'] . ' AFTER count, ADD COLUMN questionid ' . $definitions['contentwords']['questionid'] . ' AFTER type');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['doreindexcontent'] = true;
                break;
                //	Up to here: Version 1.0 beta 2
            //	Up to here: Version 1.0 beta 2
            case 6:
                qa_db_upgrade_query('ALTER TABLE ^userpoints ADD COLUMN cposts ' . $definitions['userpoints']['cposts'] . ' AFTER aposts');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
            case 7:
                if (!QA_FINAL_EXTERNAL_USERS) {
                    qa_db_upgrade_query('ALTER TABLE ^users ADD COLUMN sessioncode ' . $definitions['users']['sessioncode'] . ' AFTER writeip');
                    qa_db_upgrade_query($locktablesquery);
                }
                break;
            case 8:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD KEY (type, acount, created)');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecountposts'] = true;
                // for unanswered question count
                break;
                //	Up to here: Version 1.0 beta 3, 1.0, 1.0.1 beta, 1.0.1
            //	Up to here: Version 1.0 beta 3, 1.0, 1.0.1 beta, 1.0.1
            case 9:
                if (!QA_FINAL_EXTERNAL_USERS) {
                    qa_db_upgrade_query('ALTER TABLE ^users CHANGE COLUMN resetcode emailcode ' . $definitions['users']['emailcode'] . ', ADD COLUMN flags ' . $definitions['users']['flags'] . ' AFTER sessioncode');
                    qa_db_upgrade_query($locktablesquery);
                    qa_db_upgrade_query('UPDATE ^users SET flags=1');
                }
                break;
            case 10:
                qa_db_upgrade_query('UNLOCK TABLES');
                qa_db_upgrade_query(qa_db_create_table_sql('categories', array('categoryid' => $definitions['categories']['categoryid'], 'title' => $definitions['categories']['title'], 'tags' => $definitions['categories']['tags'], 'qcount' => $definitions['categories']['qcount'], 'position' => $definitions['categories']['position'], 'PRIMARY KEY (categoryid)', 'UNIQUE tags (tags)', 'UNIQUE position (position)')));
                // hard-code list of columns and indexes to ensure we ignore any added at a later stage
                $locktablesquery .= ', ^categories WRITE';
                qa_db_upgrade_query($locktablesquery);
                break;
            case 11:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD CONSTRAINT ^posts_ibfk_2 FOREIGN KEY (parentid) REFERENCES ^posts(postid), ADD COLUMN categoryid ' . $definitions['posts']['categoryid'] . ' AFTER parentid, ADD KEY categoryid (categoryid, type, created), ADD CONSTRAINT ^posts_ibfk_3 FOREIGN KEY (categoryid) REFERENCES ^categories(categoryid) ON DELETE SET NULL');
                // foreign key on parentid important now that deletion is possible
                qa_db_upgrade_query($locktablesquery);
                break;
            case 12:
                qa_db_upgrade_query('UNLOCK TABLES');
                qa_db_upgrade_query(qa_db_create_table_sql('pages', array('pageid' => $definitions['pages']['pageid'], 'title' => $definitions['pages']['title'], 'nav' => $definitions['pages']['nav'], 'position' => $definitions['pages']['position'], 'flags' => $definitions['pages']['flags'], 'tags' => $definitions['pages']['tags'], 'heading' => $definitions['pages']['heading'], 'content' => $definitions['pages']['content'], 'PRIMARY KEY (pageid)', 'UNIQUE tags (tags)', 'UNIQUE position (position)')));
                // hard-code list of columns and indexes to ensure we ignore any added at a later stage
                $locktablesquery .= ', ^pages WRITE';
                qa_db_upgrade_query($locktablesquery);
                break;
            case 13:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN createip ' . $definitions['posts']['createip'] . ' AFTER cookieid, ADD KEY createip (createip, created)');
                qa_db_upgrade_query($locktablesquery);
                break;
            case 14:
                qa_db_upgrade_query('ALTER TABLE ^userpoints DROP COLUMN qvotes, DROP COLUMN avotes, ADD COLUMN qupvotes ' . $definitions['userpoints']['qupvotes'] . ' AFTER aselecteds, ADD COLUMN qdownvotes ' . $definitions['userpoints']['qdownvotes'] . ' AFTER qupvotes, ADD COLUMN aupvotes ' . $definitions['userpoints']['aupvotes'] . ' AFTER qdownvotes, ADD COLUMN adownvotes ' . $definitions['userpoints']['adownvotes'] . ' AFTER aupvotes');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
//.........这里部分代码省略.........
开发者ID:kosmoluna,项目名称:question2answer,代码行数:101,代码来源:install.php

示例11: init_queries

    public function init_queries($queries, $tableslc)
    {
        $tablename = qa_db_add_table_prefix('ra_email_queue');
        if (!in_array($tablename, $tableslc)) {
            $queries[] = '
				CREATE TABLE IF NOT EXISTS ^ra_email_queue (
				  id int(6) NOT NULL AUTO_INCREMENT,
				  event varchar(250) NOT NULL,
				  body text NOT NULL,
				  created_by varchar(250) NOT NULL,
				  created_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				  status tinyint(1) DEFAULT "0",
				  sent_on timestamp NULL DEFAULT NULL,
				  PRIMARY KEY (id)
				) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
			';
        }
        $tablename = qa_db_add_table_prefix('ra_email_queue_receiver');
        if (!in_array($tablename, $tableslc)) {
            $queries[] = '
				CREATE TABLE IF NOT EXISTS ^ra_email_queue_receiver (
				  id int(6) NOT NULL AUTO_INCREMENT,
				  userid int(10) NOT NULL,
				  email varchar(250) NOT NULL,
				  name varchar(250) NOT NULL,
				  handle varchar(20) NULL,
				  queue_id int(6) NOT NULL,
				  PRIMARY KEY (id)
				) ENGINE=MyISAM DEFAULT CHARSET=utf8;
			';
        }
        return $queries;
    }
开发者ID:rahularyan,项目名称:dude-theme,代码行数:33,代码来源:addon.php

示例12: qa_db_prefix_callback

/**
 * Callback function to add table prefixes, as used in qa_db_apply_sub().
 */
function qa_db_prefix_callback($matches)
{
    return qa_db_add_table_prefix($matches[1]);
}
开发者ID:ronkeizer,项目名称:question2answer,代码行数:7,代码来源:qa-db.php

示例13: qa_db_upgrade_tables

function qa_db_upgrade_tables()
{
    require_once QA_INCLUDE_DIR . 'qa-app-recalc.php';
    $definitions = qa_db_table_definitions();
    $keyrecalc = array();
    //	Write-lock all QA tables before we start so no one can read or write anything
    $keydbtables = qa_array_to_lower_keys(qa_db_read_all_values(qa_db_query_raw('SHOW TABLES')));
    foreach ($definitions as $rawname => $definition) {
        if (isset($keydbtables[strtolower(qa_db_add_table_prefix($rawname))])) {
            $locks[] = '^' . $rawname . ' WRITE';
        }
    }
    $locktablesquery = 'LOCK TABLES ' . implode(', ', $locks);
    qa_db_upgrade_query($locktablesquery);
    //	Upgrade it step-by-step until it's up to date (do LOCK TABLES after ALTER TABLE because the lock can sometimes be lost)
    while (1) {
        $version = qa_db_get_db_version();
        if ($version >= QA_DB_VERSION_CURRENT) {
            break;
        }
        $newversion = $version + 1;
        qa_db_upgrade_progress(QA_DB_VERSION_CURRENT - $version . ' upgrade step/s remaining...');
        switch ($newversion) {
            //	Up to here: Version 1.0 beta 1
            case 2:
                qa_db_upgrade_query('ALTER TABLE ^posts DROP COLUMN votes, ADD COLUMN (upvotes ' . $definitions['posts']['upvotes'] . ', downvotes ' . $definitions['posts']['downvotes'] . ')');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecountposts'] = true;
                break;
            case 3:
                qa_db_upgrade_query('ALTER TABLE ^userpoints ADD COLUMN (upvoteds ' . $definitions['userpoints']['upvoteds'] . ', downvoteds ' . $definitions['userpoints']['downvoteds'] . ')');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
            case 4:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN lastuserid ' . $definitions['posts']['lastuserid'] . ', CHANGE COLUMN updated updated ' . $definitions['posts']['updated']);
                qa_db_upgrade_query($locktablesquery);
                qa_db_upgrade_query('UPDATE ^posts SET updated=NULL WHERE updated=0 OR updated=created');
                break;
            case 5:
                qa_db_upgrade_query('ALTER TABLE ^contentwords ADD COLUMN (type ' . $definitions['contentwords']['type'] . ', questionid ' . $definitions['contentwords']['questionid'] . ')');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['doreindexposts'] = true;
                break;
                //	Up to here: Version 1.0 beta 2
            //	Up to here: Version 1.0 beta 2
            case 6:
                qa_db_upgrade_query('ALTER TABLE ^userpoints ADD COLUMN cposts ' . $definitions['userpoints']['cposts']);
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
            case 7:
                if (!QA_FINAL_EXTERNAL_USERS) {
                    qa_db_upgrade_query('ALTER TABLE ^users ADD COLUMN sessioncode ' . $definitions['users']['sessioncode']);
                    qa_db_upgrade_query($locktablesquery);
                }
                break;
            case 8:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD KEY (type, acount, created)');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecountposts'] = true;
                // for unanswered question count
                break;
                //	Up to here: Version 1.0 beta 3, 1.0, 1.0.1 beta, 1.0.1
            //	Up to here: Version 1.0 beta 3, 1.0, 1.0.1 beta, 1.0.1
            case 9:
                if (!QA_FINAL_EXTERNAL_USERS) {
                    qa_db_upgrade_query('ALTER TABLE ^users CHANGE COLUMN resetcode emailcode ' . $definitions['users']['emailcode'] . ', ADD COLUMN flags ' . $definitions['users']['flags']);
                    qa_db_upgrade_query($locktablesquery);
                    qa_db_upgrade_query('UPDATE ^users SET flags=1');
                }
                break;
            case 10:
                qa_db_upgrade_query(qa_db_create_table_sql('categories', array('categoryid' => $definitions['categories']['categoryid'], 'title' => $definitions['categories']['title'], 'tags' => $definitions['categories']['tags'], 'qcount' => $definitions['categories']['qcount'], 'position' => $definitions['categories']['position'], 'PRIMARY KEY (categoryid)', 'UNIQUE tags (tags)', 'UNIQUE position (position)')));
                // hard-code list of columns and indexes to ensure we ignore any added at a later stage
                $locktablesquery .= ', ^categories WRITE';
                qa_db_upgrade_query($locktablesquery);
                break;
            case 11:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD CONSTRAINT ^posts_ibfk_2 FOREIGN KEY (parentid) REFERENCES ^posts(postid), ADD COLUMN categoryid ' . $definitions['posts']['categoryid'] . ', ADD KEY categoryid (categoryid, type, created), ADD CONSTRAINT ^posts_ibfk_3 FOREIGN KEY (categoryid) REFERENCES ^categories(categoryid) ON DELETE SET NULL');
                // foreign key on parentid important now that deletion is possible
                qa_db_upgrade_query($locktablesquery);
                break;
            case 12:
                qa_db_upgrade_query(qa_db_create_table_sql('pages', array('pageid' => $definitions['pages']['pageid'], 'title' => $definitions['pages']['title'], 'nav' => $definitions['pages']['nav'], 'position' => $definitions['pages']['position'], 'flags' => $definitions['pages']['flags'], 'tags' => $definitions['pages']['tags'], 'heading' => $definitions['pages']['heading'], 'content' => $definitions['pages']['content'], 'PRIMARY KEY (pageid)', 'UNIQUE tags (tags)', 'UNIQUE position (position)')));
                // hard-code list of columns and indexes to ensure we ignore any added at a later stage
                $locktablesquery .= ', ^pages WRITE';
                qa_db_upgrade_query($locktablesquery);
                break;
            case 13:
                qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN createip ' . $definitions['posts']['createip'] . ', ADD KEY createip (createip, created)');
                qa_db_upgrade_query($locktablesquery);
                break;
            case 14:
                qa_db_upgrade_query('ALTER TABLE ^userpoints DROP COLUMN qvotes, DROP COLUMN avotes, ADD COLUMN (qupvotes ' . $definitions['userpoints']['qupvotes'] . ', qdownvotes ' . $definitions['userpoints']['qdownvotes'] . ', aupvotes ' . $definitions['userpoints']['aupvotes'] . ', adownvotes ' . $definitions['userpoints']['adownvotes'] . ')');
                qa_db_upgrade_query($locktablesquery);
                $keyrecalc['dorecalcpoints'] = true;
                break;
                //	Up to here: Version 1.2 beta 1
            //	Up to here: Version 1.2 beta 1
//.........这里部分代码省略.........
开发者ID:TheProjecter,项目名称:microprobe,代码行数:101,代码来源:qa-db-install.php


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