• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP table_exists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: xmldb_blocktype_taggedposts_upgrade

function xmldb_blocktype_taggedposts_upgrade($oldversion = 0)
{
    if ($oldversion < 2015011500) {
        $table = new XMLDBTable('blocktype_taggedposts_tags');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype'));
        if (!table_exists($table)) {
            create_table($table);
            $rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata');
            while ($bi = $rs->FetchRow()) {
                // Each block will have only one tag (because we combined this upgrade block
                // with the upgrade block for the "multiple tags" enhancement.
                $configdata = unserialize($bi['configdata']);
                if (!empty($configdata['tagselect'])) {
                    $todb = new stdClass();
                    $todb->block_instance = $bi['id'];
                    $todb->tag = $configdata['tagselect'];
                    $todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE;
                    insert_record('blocktype_taggedposts_tags', $todb);
                }
            }
        }
    }
    return true;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:upgrade.php


示例2: create_tables

function create_tables($db_prefix, $drop_tables = 1)
{
    //check if tables exists and if drop_tables is 1
    table_exists($db_prefix . "session", $drop_tables);
    table_exists($db_prefix . "tracks_hh", $drop_tables);
    print "<LI> Created tables " . substr($tables, 0, -2) . "<BR />";
}
开发者ID:sharedgeo,项目名称:TicketsCAD-SharedGeo-Dev,代码行数:7,代码来源:parser.php


示例3: cmc_call

function cmc_call($majorcode, $semester, $year)
{
    $database = $majorcode . "_" . $semester . "_" . $year . "_req_courses";
    if (table_exists($database) != 1) {
        if (strpos($semester, 'fall') !== false) {
            $Csemester = "Fall";
        }
        if (strpos($semester, 'spring') !== false) {
            $Csemester = "Spring";
        }
        if (strpos($semester, 'summer') !== false) {
            $Csemester = "Summer";
        }
        $full_semester = $Csemester . " " . $year;
        //echo $full_semester;
        //echo "$database";
        $test = curriculum_request($majorcode, $full_semester);
        //echo "<pre>"; print_r($test);
        //echo "iambatman live";
        if ($test != 1) {
            $result = cms_to_database($majorcode, $semester, $year, $test);
            // uncheck this after meeting
            return 1;
            //print_r($test);
        } else {
            return 0;
        }
    } else {
        return 1;
    }
}
开发者ID:CIS317F15StudentRM,项目名称:StudentDeptRM,代码行数:31,代码来源:cms_call.php


示例4: downgrade

    public function downgrade(PDO $pdo)
    {
        if (table_exists($pdo, $pdo->prefix . 'calendar')) {
            $pdo->exec(<<<SQL
ALTER TABLE
    {$pdo->prefix}calendar
DROP COLUMN
    userid
SQL
);
        }
        if (table_exists($pdo, $pdo->prefix . 'registry')) {
            $stmt = $pdo->prepare(<<<SQL
UPDATE
    {$pdo->prefix}registry
SET
    keyvalue = :version
WHERE
    keyname = 'version'
SQL
);
            $stmt->bindValue(':version', $this->fromVersion, PDO::PARAM_STR);
            $stmt->execute();
        }
    }
开发者ID:adrianbroher,项目名称:thwboard,代码行数:25,代码来源:ThWboardMigration.1.php


示例5: pre_check_3

function pre_check_3()
{
    if (table_exists("bayes_token")) {
        return array(false, "Already exists");
    } else {
        return array(true, "");
    }
}
开发者ID:einheit,项目名称:mailguard_legacy,代码行数:8,代码来源:3.php


示例6: pre_check_4

function pre_check_4()
{
    if (table_exists("maia_tokens")) {
        return array(false, "Already exists");
    } else {
        return array(true, "");
    }
}
开发者ID:einheit,项目名称:mailguard_legacy,代码行数:8,代码来源:4.php


示例7: clean_stale_tables

 /**
  * detect and clean up any old test tables lying around
  * as of phpunit 3.4, there's no corollary to bootstrap to clean up,
  * so this will actually be invoked every single time
  * which is quite annoying
  */
 public function clean_stale_tables()
 {
     if (table_exists(new XMLDBTable('config'))) {
         if (empty($GLOBALS['TESTDROPSTALEDB']) || $GLOBALS['TESTDROPSTALEDB'] !== true) {
             throw new UnitTestBootstrapException('Stale test tables found, and drop option not set.  Refusing to run tests');
         }
         log_info('Stale test tables found, and drop option is set.  Dropping them before running tests');
         $this->uninstall_mahara();
         log_info('Done');
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:phpunit.php


示例8: migrate

function migrate()
{
    global $db_tables;
    foreach ($db_tables as $table => $fields) {
        if (table_exists($table)) {
            //compare the field names of the table with the field names in the array
            //describe table
            $existing_fields = array();
            $field_names = array();
            $result = mysql_query("DESCRIBE " . $table);
            while ($data = mysql_fetch_assoc($result)) {
                array_push($existing_fields, $data["Field"]);
            }
            foreach ($fields as $name => $type) {
                array_push($field_names, $name);
            }
            //get any fields that were not present. Subtract existing fields
            $field_names = array_diff($field_names, $existing_fields);
            if (sizeof($field_names) > 0) {
                //if there is any difference between existing and expected tables
                foreach ($field_names as $name) {
                    $sql = "ALTER TABLE `{$table}` ADD COLUMN `{$name}` " . $db_tables[$table][$name] . ";";
                    if (mysql_query($sql)) {
                        echo "<BR> Added column {$name} to {$table} <BR>";
                    } else {
                        echo "<BR> Failed to add {$name} to {$table} <BR>";
                    }
                }
            } else {
                echo "<BR>No missing fields in {$table}";
            }
        } else {
            //creates a new table with our default timestamps
            $sql = "CREATE TABLE `{$table}` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `created_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n                  `updated_at` timestamp NOT NULL default '0000-00-00 00:00:00',";
            foreach ($fields as $name => $type) {
                $sql .= "`{$name}` {$type},\n";
            }
            $sql .= "PRIMARY KEY  (`id`)\n                    ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1";
            if (mysql_query($sql)) {
                echo "<BR> Added table {$table} <BR>";
            } else {
                echo "<BR> Failed to add table {$table} <BR>";
            }
        }
    }
}
开发者ID:andrewdrane,项目名称:ssorm,代码行数:46,代码来源:migrate.php


示例9: install

 public function install()
 {
     if (!table_exists('__meta_user') && !table_exists('__meta_code')) {
         $sql = "CREATE TABLE IF NOT EXISTS `__meta_code` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `table` varchar(32) NOT NULL,\n  `action` varchar(32) NOT NULL,\n  `code` mediumtext NOT NULL,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `table` (`table`,`action`)\n)";
         run_sql($sql);
         $sql = "CREATE TABLE IF NOT EXISTS `__meta_user` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `email` varchar(255) NOT NULL,\n  `password` varchar(32) NOT NULL,\n  PRIMARY KEY (`id`)\n) ";
         run_sql($sql);
         $email = 'admin' . rand(1, 999) . '@admin.com';
         $password = substr(md5(rand(10000, 8000) . time()), 0, 8);
         $sql = "INSERT INTO `__meta_user` ( `email` , `password` ) VALUES ( '" . s($email) . "' , '" . md5($password) . "' ) ";
         run_sql($sql);
         if (mysql_errno() == 0) {
             return info_page("初始化成功,请使用【" . $email . "】和【" . $password . "】<a href='?a=login' target='_blank'>登录</a>。您可以通过phpmyadmin修改【__meta_user】表来管理账户" . '<br /><br /><a href="http://ftqq.com/2012/01/10/build-a-rest-server-in-5-minutes/" target="_blank">使用教程</a>');
         }
     }
     return info_page("已经初始化或数据库错误,请稍后重试");
 }
开发者ID:jfojfo,项目名称:LazyREST,代码行数:17,代码来源:default.class.php


示例10: log_event

/**
 * Logs an event to make sure it's not triggered again
 * @params:
 *		$event						:array
 *	 		$event['issue_id']		:integer, the id of the issue to be logeed with the event
 *			$event['initiative_id']	:integer, the id of the initiative to be looged with the event
 *			$event['job']			:string, the job that handled the issue
 * @returns true on success, dies otherwise
 */
function log_event($event)
{
    global $db_events_table;
    //the events table's name for each bot is defined in update_twitter_bot.php right before the bot is processed
    $time = time();
    if (!table_exists($db_events_table)) {
        create_table($db_events_table, 'time INT, issue_id INT, initiative_id INT, job CHAR(80)');
    }
    $query = "INSERT INTO {$db_events_table} (time, issue_id, initiative_id, job) VALUES({$time}, {$event['issue_id']} , {$event['initiative_id']} , '{$event['job']}')";
    $result = mysql_query($query);
    $error = mysql_errno();
    if ($error != 0) {
        log_this("error: tried to log event ({$event['issue_id']} , {$event['issue_id']}, '{$event['job']})", mysql_error() . ": \n" . $query);
        die("Unable to log event. MySQL error: " . $error);
    } else {
        log_this("success: logged event ({$event['issue_id']} ,{$event['initiative_id']}, '{$event['job']})");
        return true;
    }
}
开发者ID:rhotep,项目名称:LiquidFeedback-Twitter-Bot,代码行数:28,代码来源:bot.php


示例11: xmldb_block_tao_certification_path_upgrade

function xmldb_block_tao_certification_path_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of "/lib/ddllib.php" function calls
    /// }
    if ($result && $oldversion < 2008111204) {
        //New version in version.php
        $table = new XMLDBTable('tao_user_certification_status');
        if (!table_exists($table)) {
            //this table doesn't exist so create it!
            $result = install_from_xmldb_file("{$CFG->dirroot}/blocks/tao_certification_path/db/install.xml");
        }
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:21,代码来源:upgrade.php


示例12: log_this

/**
 * Appends a row to the log table
 * @params
 *		$key	:string, a short description of the data to be stored
 * 		$data	:the data to be stored
 * @returns true on success, dies otherwise
 */
function log_this($key, $data = '')
{
    $key = mysql_escape_string($key);
    $data = mysql_escape_string($data);
    if (!table_exists(DB_TABLE_LOG)) {
        create_table(DB_TABLE_LOG, "id INT AUTO_INCREMENT, time INT, label TEXT, data TEXT, PRIMARY KEY (id)");
    } else {
        // nothing is kept older than 3 days
        $time = time() - 60 * 60 * 24 * 3;
        $query = "DELETE from " . DB_TABLE_LOG . " WHERE time<{$time}";
        $result = mysql_query($query);
        if (mysql_errno != 0) {
            die("MySQL error: " . mysql_errno());
        }
    }
    $query = "INSERT INTO " . DB_TABLE_LOG . "(time, label, data) VALUES ( " . time() . ", \"{$key}\", \"{$data}\")";
    $result = mysql_query($query);
    if (mysql_errno != 0) {
        die("MySQL error: " . mysql_errno());
    } else {
        return true;
    }
}
开发者ID:rhotep,项目名称:LiquidFeedback-Twitter-Bot,代码行数:30,代码来源:tools.php


示例13: cm_load_config

/**
 * Load up the curriculum management global config values (copied from Moodle).
 *
 */
function cm_load_config()
{
    global $CFG, $CURMAN;
    /// Ensure that the table actually exists before we query records from it.
    require_once $CFG->libdir . '/ddllib.php';
    $table = new XMLDBTable(CMCONFIGTABLE);
    if (!table_exists($table)) {
        return $CURMAN->config;
    }
    if ($configs = get_records(CMCONFIGTABLE)) {
        /// Allow settings in the config.php file to override.
        $localcfg = (array) $CURMAN->config;
        foreach ($configs as $config) {
            if (!isset($localcfg[$config->name])) {
                $localcfg[$config->name] = $config->value;
            }
        }
        $localcfg = (object) $localcfg;
        return $localcfg;
    } else {
        // preserve $CFG if DB returns nothing or error
        return $CURMAN->config;
    }
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:28,代码来源:lib.php


示例14: get_site_languages

 function get_site_languages($lang = '', $active = '')
 {
     if (table_exists('site_languages', MAINSITE_DB)) {
         $db_languages = MAINSITE_DB;
     } else {
         $db_languages = CAMALEO_DB;
     }
     # set the database to use
     #
     $sql = 'SELECT ' . '`site_languages`.`lang`, ' . '`site_languages`.`descrizione`, ' . 'LCASE(`site_languages`.`flag`) AS flag, ' . 'LCASE(`site_languages`.`iso`)  AS iso, ' . '`site_languages`.`switch` ' . 'FROM `' . $db_languages . '`.`site_languages` ' . 'WHERE 1=1 ';
     if ($lang != '') {
         $sql .= 'AND lang = \'' . mysql_real_escape_string($lang) . '\' ';
     }
     if ($active != '') {
         $sql .= 'AND switch = 1 ';
     }
     $sql .= 'ORDER BY switch DESC, descrizione ASC ';
     #
     $sth = db_query($sql, __LINE__, __FILE__);
     $rows = db_fetch($sth[0], false);
     //echo $sql.'<br>';
     //var_dump($rows);
     return $rows;
 }
开发者ID:hewu,项目名称:blogwp,代码行数:24,代码来源:get_site_languages.inc.php


示例15: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB, $db;
     /// And we nedd some ddl suff
     require_once $CFG->libdir . '/ddllib.php';
     /// Here we'll acummulate all the wrong fields found
     $wrong_fields = array();
     /// Correct fields must be type bigint for MySQL and int8 for PostgreSQL
     switch ($CFG->dbfamily) {
         case 'mysql':
             $correct_type = 'bigint';
             break;
         case 'postgres':
             $correct_type = 'int8';
             break;
         default:
             $correct_type = NULL;
     }
     /// Do the job, setting $result as needed
     /// Get the confirmed to decide what to do
     $confirmed = optional_param('confirmed', false, PARAM_BOOL);
     /// If  not confirmed, show confirmation box
     if (!$confirmed) {
         $o = '<table class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
         $o .= '  <tr><td class="generalboxcontent">';
         $o .= '    <p class="centerpara">' . $this->str['confirmcheckbigints'] . '</p>';
         if ($CFG->dbfamily == 'mysql') {
             $o .= '    <p class="centerpara">' . $this->str['mysqlextracheckbigints'] . '</p>';
         }
         $o .= '    <table class="boxaligncenter" cellpadding="20"><tr><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=check_bigints&amp;sesskey=' . sesskey() . '&amp;confirmed=yes" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['yes'] . '" /></fieldset></form></div>';
         $o .= '      </td><td>';
         $o .= '      <div class="singlebutton">';
         $o .= '        <form action="index.php?action=main_view" method="post"><fieldset class="invisiblefieldset">';
         $o .= '          <input type="submit" value="' . $this->str['no'] . '" /></fieldset></form></div>';
         $o .= '      </td></tr>';
         $o .= '    </table>';
         $o .= '  </td></tr>';
         $o .= '</table>';
         $this->output = $o;
     } else {
         /// The back to edit table button
         $b = ' <p class="centerpara buttons">';
         $b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
         $b .= '</p>';
         /// Iterate over $XMLDB->dbdirs, loading their XML data to memory
         if ($XMLDB->dbdirs) {
             $dbdirs =& $XMLDB->dbdirs;
             $o = '<ul>';
             foreach ($dbdirs as $dbdir) {
                 /// Only if the directory exists
                 if (!$dbdir->path_exists) {
                     continue;
                 }
                 /// Load the XML file
                 $xmldb_file = new XMLDBFile($dbdir->path . '/install.xml');
                 /// Load the needed XMLDB generator
                 $classname = 'XMLDB' . $CFG->dbtype;
                 $generator = new $classname();
                 $generator->setPrefix($CFG->prefix);
                 /// Only if the file exists
                 if (!$xmldb_file->fileExists()) {
                     continue;
                 }
                 /// Load the XML contents to structure
                 $loaded = $xmldb_file->loadXMLStructure();
                 if (!$loaded || !$xmldb_file->isLoaded()) {
                     notify('Errors found in XMLDB file: ' . $dbdir->path . '/install.xml');
                     continue;
                 }
                 /// Arriving here, everything is ok, get the XMLDB structure
                 $structure = $xmldb_file->getStructure();
                 $o .= '    <li>' . str_replace($CFG->dirroot . '/', '', $dbdir->path . '/install.xml');
                 /// Getting tables
                 if ($xmldb_tables = $structure->getTables()) {
                     $o .= '        <ul>';
                     /// Foreach table, process its fields
                     foreach ($xmldb_tables as $xmldb_table) {
                         /// Skip table if not exists
                         if (!table_exists($xmldb_table)) {
                             continue;
                         }
                         /// Fetch metadata from phisical DB. All the columns info.
                         if ($metacolumns = $db->MetaColumns($CFG->prefix . $xmldb_table->getName())) {
                             $metacolumns = array_change_key_case($metacolumns, CASE_LOWER);
                         } else {
                             //// Skip table if no metacolumns is available for it
                             continue;
//.........这里部分代码省略.........
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:101,代码来源:check_bigints.class.php


示例16: xmldb_core_upgrade


//.........这里部分代码省略.........
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('lastauthinstance');
        drop_field($table, $field);
    }
    if ($oldversion < 2009080600) {
        $table = new XMLDBTable('view');
        $index = new XMLDBIndex('view_own_type_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('owner'));
        if (!index_exists($table, $index)) {
            // Delete duplicate profile views if there are any, then add an index
            // that will prevent it happening again - but only on postgres, as it's
            // the only db that supports partial indexes
            if ($viewdata = get_records_sql_array("\n                SELECT owner, id\n                FROM {view}\n                WHERE owner IN (\n                    SELECT owner\n                    FROM {view}\n                    WHERE type = 'profile'\n                    GROUP BY owner\n                    HAVING COUNT(*) > 1\n                )\n                AND type = 'profile'\n                ORDER BY owner, id", array())) {
                require_once 'view.php';
                $seen = array();
                foreach ($viewdata as $record) {
                    $seen[$record->owner][] = $record->id;
                }
                foreach ($seen as $owner => $views) {
                    // Remove the first one, which is their real profile view
                    array_shift($views);
                    foreach ($views as $viewid) {
                        delete_records('artefact_feedback', 'view', $viewid);
                        delete_records('view_feedback', 'view', $viewid);
                        delete_records('view_access', 'view', $viewid);
                        delete_records('view_access_group', 'view', $viewid);
                        delete_records('view_access_usr', 'view', $viewid);
                        delete_records('view_access_token', 'view', $viewid);
                        delete_records('view_autocreate_grouptype', 'view', $viewid);
                        delete_records('view_tag', 'view', $viewid);
                        delete_records('usr_watchlist_view', 'view', $viewid);
                        if ($blockinstanceids = get_column('block_instance', 'id', 'view', $viewid)) {
                            foreach ($blockinstanceids as $id) {
                                if (table_exists(new XMLDBTable('blocktype_wall_post'))) {
                                    delete_records('blocktype_wall_post', 'instance', $id);
                                }
                                delete_records('view_artefact', 'block', $id);
                                delete_records('block_instance', 'id', $id);
                            }
                        }
                        delete_records('view', 'id', $viewid);
                    }
                }
            }
            if (is_postgres()) {
                execute_sql("CREATE UNIQUE INDEX {view_own_type_uix} ON {view}(owner) WHERE type = 'profile'");
            }
        }
    }
    if ($oldversion < 2009080601) {
        execute_sql("DELETE FROM {group_member_invite} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'invite')");
        execute_sql("DELETE FROM {group_member_request} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'request')");
    }
    if ($oldversion < 2009081800) {
        $event = (object) array('name' => 'creategroup');
        ensure_record_exists('event_type', $event, $event);
    }
    if ($oldversion < 2009082400) {
        $table = new XMLDBTable('usr_registration');
        $field = new XMLDBField('username');
        drop_field($table, $field);
        $field = new XMLDBField('salt');
        drop_field($table, $field);
        $field = new XMLDBField('password');
        drop_field($table, $field);
    }
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例17: install

 public static function install($db)
 {
     $tables = self::getDbTables();
     foreach ($tables as $table) {
         if (!table_exists($table)) {
             if (!create_table($table)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:POETGroup,项目名称:moodle-local_globalmessage,代码行数:12,代码来源:base.php


示例18: check_upgrades


//.........这里部分代码省略.........
                if ($plugin == 'artefact') {
                    // go check it for blocks as well
                    $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                    if (!is_dir($btlocation)) {
                        continue;
                    }
                    $btdirhandle = opendir($btlocation);
                    while (false !== ($btdir = readdir($btdirhandle))) {
                        if (strpos($btdir, '.') === 0) {
                            continue;
                        }
                        if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                            continue;
                        }
                        $plugins[] = array('blocktype', $dir . '/' . $btdir);
                    }
                }
            }
        }
    }
    foreach ($plugins as $plugin) {
        $plugintype = $plugin[0];
        $pluginname = $plugin[1];
        $pluginpath = "{$plugin['0']}/{$plugin['1']}";
        $pluginkey = "{$plugin['0']}.{$plugin['1']}";
        if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
            // sigh.. we're a bit special...
            $bits = explode('/', $pluginname);
            $pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
        }
        // Don't try to get the plugin info if we are installing - it will
        // definitely fail
        $pluginversion = 0;
        if (!$installing && table_exists(new XMLDBTable($plugintype . '_installed'))) {
            if ($plugintype == 'blocktype' && strpos($pluginname, '/')) {
                $bits = explode('/', $pluginname);
                $installed = get_record('blocktype_installed', 'name', $bits[1], 'artefactplugin', $bits[0]);
            } else {
                $installed = get_record($plugintype . '_installed', 'name', $pluginname);
            }
            if ($installed) {
                $pluginversion = $installed->version;
                $pluginrelease = $installed->release;
            }
        }
        $config = new StdClass();
        require get_config('docroot') . $pluginpath . '/version.php';
        if (isset($config->disablelogin) && !empty($config->disablelogin)) {
            $disablelogin = true;
        }
        if (empty($pluginversion)) {
            if (empty($installing) && $pluginkey != $name) {
                continue;
            }
            $plugininfo = new StdClass();
            $plugininfo->install = true;
            $plugininfo->to = $config->version;
            $plugininfo->torelease = $config->release;
            if (property_exists($config, 'requires_config')) {
                $plugininfo->requires_config = $config->requires_config;
            }
            if (property_exists($config, 'requires_parent')) {
                $plugininfo->requires_parent = $config->requires_parent;
            }
            $toupgrade[$pluginkey] = $plugininfo;
        } else {
开发者ID:Br3nda,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例19: log_info

        } else {
            $data['upgrade'] = true;
            log_info('Upgraded ' . $data['key'] . ' to ' . $data['newversion']);
        }
        $data['error'] = false;
        $data['feedback'] = $SESSION->render_messages();
        if (param_boolean('last', false)) {
            delete_records('config', 'field', '_upgrade');
        }
        json_reply(false, $data);
        exit;
    } catch (Exception $e) {
        list($texttrace, $htmltrace) = log_build_backtrace($e->getTrace());
        $data['errormessage'] = $e->getMessage() . '<br>' . $htmltrace;
        $data['error'] = true;
        if (table_exists(new XMLDBTable('config'))) {
            delete_records('config', 'field', '_upgrade');
        }
        json_reply('local', $data);
        exit;
    }
} else {
    // Nothing to upgrade.  This can happen when a plugin upgrade was found
    // in the original list of upgrades generated on admin/upgrade.php, but
    // the core upgrade has already upgraded that plugin, so we're trying to
    // upgrade it again.
    // It seems a bit wrong.  For one thing, the core upgrade probably
    // shouldn't upgrade plugins past the version that was current at the
    // time the core upgrade was written.
    $data['error'] = false;
    $data['message'] = get_string('nothingtoupgrade', 'admin');
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:upgrade.json.php


示例20: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     //$this->does_generate = ACTION_NONE;
     $this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB, $db;
     /// ADD YOUR CODE HERE
     require_once $CFG->libdir . '/ddllib.php';
     /// Where all the tests will be stored
     $tests = array();
     /// The back to edit table button
     $b = ' <p class="centerpara buttons">';
     $b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
     $b .= '</p>';
     $o = $b;
     /// Silenty drop any previous test tables
     $table = new XMLDBTable('testtable');
     if (table_exists($table)) {
         $status = drop_table($table, true, false);
     }
     $table = new XMLDBTable('anothertest');
     if (table_exists($table)) {
         $status = drop_table($table, true, false);
     }
     $table = new XMLDBTable('newnameforthetable');
     if (table_exists($table)) {
         $status = drop_table($table, true, false);
     }
     /// 1st test. Complete table creation.
     $table = new XMLDBTable('testtable');
     $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
     $table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general');
     $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null);
     $table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
     $table->addFieldInfo('logo', XMLDB_TYPE_BINARY, 'big', null, XMLDB_NOTNULL, null, null, null);
     $table->addFieldInfo('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1');
     $table->addFieldInfo('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('grade', XMLDB_TYPE_NUMBER, '20,0', XMLDB_UNSIGNED, null, null, null, null, null);
     $table->addFieldInfo('percent', XMLDB_TYPE_NUMBER, '5,2', null, null, null, null, null, null);
     $table->addFieldInfo('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addFieldInfo('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
     $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->addKeyInfo('type-name', XMLDB_KEY_UNIQUE, array('type', 'name'));
     $table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
     $table->addIndexInfo('rsstype', XMLDB_INDEX_UNIQUE, array('rsstype'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     /// Get SQL code and execute it
     $test = new stdClass();
     $test->sql = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, true);
     $test->status = create_table($table, false, false);
     if (!$test->status) {
         $test->error = $db->ErrorMsg();
     }
     $tests['create table'] = $test;
     /// 2nd test. drop table
     if ($test->status) {
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $table->getDropTableSQL($CFG->dbtype, $CFG->prefix, true);
         $test->status = drop_table($table, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
         }
         $tests['drop table'] = $test;
     }
     /// 3rd test. creating another, smaller table
     if ($test->status) {
         $table = new XMLDBTable('anothertest');
         $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
         $table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
         $table->addFieldInfo('secondname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('avatar', XMLDB_TYPE_BINARY, 'medium', null, null, null, null, null, null);
         $table->addFieldInfo('grade', XMLDB_TYPE_NUMBER, '20,10', null, null, null, null, null);
         $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, true);
         $test->status = create_table($table, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:test.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP table_header函数代码示例发布时间:2022-05-23
下一篇:
PHP table_end函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap