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


PHP xmldb_table::setComment方法代码示例

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


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

示例1: test_reorder_rows

 public function test_reorder_rows()
 {
     global $DB;
     $dbman = $DB->get_manager();
     $this->resetAfterTest();
     $table = new xmldb_table('test_table');
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $tablename = $table->getName();
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('otherid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('otherdata', XMLDB_TYPE_TEXT, 'big', null, null, null);
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('unique', XMLDB_KEY_UNIQUE, array('otherid', 'sortorder'));
     $dbman->create_table($table);
     // Rows intentionally added in a slightly 'random' order.
     // Note we are testing hat the otherid = 1 rows don't get messed up,
     // as well as testing that the otherid = 2 rows are updated correctly.
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 4'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'));
     $DB->insert_record($tablename, array('otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'));
     $DB->insert_record($tablename, array('otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 2'));
     update_field_with_unique_index($tablename, 'sortorder', array(1 => 4, 2 => 1, 3 => 3, 4 => 2), array('otherid' => 2));
     $this->assertEquals(array(3 => (object) array('id' => 3, 'otherid' => 1, 'sortorder' => 1, 'otherdata' => 'Other 1'), 4 => (object) array('id' => 4, 'otherid' => 1, 'sortorder' => 2, 'otherdata' => 'Other 2')), $DB->get_records($tablename, array('otherid' => 1), 'sortorder'));
     $this->assertEquals(array(2 => (object) array('id' => 2, 'otherid' => 2, 'sortorder' => 1, 'otherdata' => 'To become 1'), 6 => (object) array('id' => 6, 'otherid' => 2, 'sortorder' => 2, 'otherdata' => 'To become 2'), 5 => (object) array('id' => 5, 'otherid' => 2, 'sortorder' => 3, 'otherdata' => 'To stay at 3'), 1 => (object) array('id' => 1, 'otherid' => 2, 'sortorder' => 4, 'otherdata' => 'To become 4')), $DB->get_records($tablename, array('otherid' => 2), 'sortorder'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:datalib_update_with_unique_index_test.php

示例2: get_test_table

 /**
  * Get a xmldb_table object for testing, deleting any existing table
  * of the same name, for example if one was left over from a previous test
  * run that crashed.
  *
  * @param string $suffix table name suffix, use if you need more test tables
  * @return xmldb_table the table object.
  */
 private function get_test_table($suffix = '')
 {
     $tablename = "test_table";
     if ($suffix !== '') {
         $tablename .= $suffix;
     }
     $table = new xmldb_table($tablename);
     $table->setComment("This is a test'n drop table. You can drop it safely");
     return new xmldb_table($tablename);
 }
开发者ID:rama1712,项目名称:moodle,代码行数:18,代码来源:dml_test.php

示例3: setUp

 public function setUp()
 {
     global $CFG, $DB, $UNITTEST;
     if (isset($UNITTEST->func_test_db)) {
         $this->tdb = $UNITTEST->func_test_db;
     } else {
         $this->tdb = $DB;
     }
     unset($CFG->xmldbreconstructprevnext);
     // remove this unhack ;-)
     $dbman = $this->tdb->get_manager();
     $table = new xmldb_table('test_table0');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'general');
     $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null);
     $table->add_field('intro', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
     $table->add_field('logo', XMLDB_TYPE_BINARY, 'big', null, XMLDB_NOTNULL, null);
     $table->add_field('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
     $table->add_field('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,0', XMLDB_UNSIGNED, null, null, null);
     $table->add_field('percent', XMLDB_TYPE_NUMBER, '5,2', null, null, null, null);
     $table->add_field('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('type-name', XMLDB_KEY_UNIQUE, array('type', 'name'));
     $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
     $table->add_index('rsstype', XMLDB_INDEX_UNIQUE, array('rsstype'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     // Second, smaller table
     $table = new xmldb_table('test_table1');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('name', XMLDB_TYPE_CHAR, '30', null, null, null, 'Moodle');
     $table->add_field('secondname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null);
     $table->add_field('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
     $table->add_field('avatar', XMLDB_TYPE_BINARY, 'medium', null, null, null, null);
     $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,10', null, null, null);
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     // make sure no tables are present!
     $this->tearDown();
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:54,代码来源:testddl.php

示例4: xmldb_lesson_upgrade

/**
 *
 * @global stdClass $CFG
 * @global moodle_database $DB
 * @global core_renderer $OUTPUT
 * @param int $oldversion
 * @return bool
 */
function xmldb_lesson_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    //GWL : To Add a custom table visited_links
    if ($oldversion < 2014051201) {
        // create new table
        $table = new xmldb_table('lesson_visited_links');
        // Set up the comment.
        $table->setComment('To store visited lession links');
        // Adding fields to table facetoface_notification_hist
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->add_field('user_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->add_field('page_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        // Adding keys to table facetoface_sessions_config
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('page_id', XMLDB_KEY_FOREIGN, array('page_id'), 'lesson_pages', array('id'));
        // Launch create table for facetoface_sessions_config
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        upgrade_mod_savepoint(true, 2014051201, 'lesson');
    }
    return true;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:45,代码来源:upgrade.php

示例5: 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, $OUTPUT;
     // Do the job, setting result as needed
     // Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $dirpath;
     // Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir = $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir = $XMLDB->editeddirs[$dirpath];
         $structure = $editeddir->xml_file->getStructure();
     }
     $tableparam = optional_param('table', NULL, PARAM_CLEAN);
     // If no table, show form
     if (!$tableparam) {
         // No postaction here
         $this->postaction = NULL;
         // Get list of tables
         $dbtables = $DB->get_tables();
         $selecttables = array();
         foreach ($dbtables as $dbtable) {
             $i = $structure->findTableInArray($dbtable);
             if ($i === NULL) {
                 $selecttables[$dbtable] = $dbtable;
             }
         }
         // Get list of after tables
         $aftertables = array();
         if ($tables = $structure->getTables()) {
             foreach ($tables as $aftertable) {
                 $aftertables[$aftertable->getName()] = $aftertable->getName();
             }
         }
         if (!$selecttables) {
             $this->errormsg = 'No tables available to be retrofitted';
             return false;
         }
         // Now build the form
         $o = '<form id="form" action="index.php" method="post">';
         $o .= '<div>';
         $o .= '    <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
         $o .= '    <input type="hidden" name ="action" value="new_table_from_mysql" />';
         $o .= '    <input type="hidden" name ="postaction" value="edit_table" />';
         $o .= '    <input type="hidden" name ="sesskey" value="' . sesskey() . '" />';
         $o .= '    <table id="formelements" class="boxaligncenter" cellpadding="5">';
         $o .= '      <tr><td><label for="menutable" accesskey="t">' . $this->str['createtable'] . ' </label>' . html_writer::select($selecttables, 'table') . '<label for="menuafter" accesskey="a">' . $this->str['aftertable'] . ' </label>' . html_writer::select($aftertables, 'after') . '</td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><input type="submit" value="' . $this->str['create'] . '" /></td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
         $o .= '    </table>';
         $o .= '</div></form>';
         $this->output = $o;
         // If table, retrofit information and, if everything works,
         // go to the table edit action
     } else {
         // Get some params (table is mandatory here)
         $tableparam = required_param('table', PARAM_CLEAN);
         $afterparam = required_param('after', PARAM_CLEAN);
         // Create one new xmldb_table
         $table = new xmldb_table(strtolower(trim($tableparam)));
         $table->setComment($table->getName() . ' table retrofitted from MySQL');
         // Get fields info from ADODb
         $dbfields = $DB->get_columns($tableparam);
         if ($dbfields) {
             foreach ($dbfields as $dbfield) {
                 // Create new XMLDB field
                 $field = new xmldb_field($dbfield->name);
                 // Set field with info retrofitted
                 $field->setFromADOField($dbfield);
                 // Add field to the table
                 $table->addField($field);
             }
         }
         // Get PK, UK and indexes info from ADODb
         $dbindexes = $DB->get_indexes($tableparam);
         if ($dbindexes) {
             $lastkey = NULL;
             //To temp store the last key processed
             foreach ($dbindexes as $indexname => $dbindex) {
                 // Add the indexname to the array
                 $dbindex['name'] = $indexname;
                 // We are handling one xmldb_key (primaries + uniques)
                 if ($dbindex['unique']) {
                     $key = new xmldb_key(strtolower($dbindex['name']));
                     // Set key with info retrofitted
                     $key->setFromADOKey($dbindex);
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:new_table_from_mysql.class.php

示例6: test_create_table

 /**
  * Test behaviour of create_table()
  */
 public function test_create_table()
 {
     $DB = $this->tdb;
     // Do not use global $DB!
     $dbman = $this->tdb->get_manager();
     // Create table.
     $table = $this->tables['test_table1'];
     $dbman->create_table($table);
     $this->assertTrue($dbman->table_exists($table));
     // Basic get_tables() test.
     $tables = $DB->get_tables();
     $this->assertArrayHasKey('test_table1', $tables);
     // Basic get_columns() tests.
     $columns = $DB->get_columns('test_table1');
     $this->assertSame('R', $columns['id']->meta_type);
     $this->assertSame('I', $columns['course']->meta_type);
     $this->assertSame('C', $columns['name']->meta_type);
     $this->assertSame('C', $columns['secondname']->meta_type);
     $this->assertSame('C', $columns['thirdname']->meta_type);
     $this->assertSame('X', $columns['intro']->meta_type);
     $this->assertSame('B', $columns['avatar']->meta_type);
     $this->assertSame('N', $columns['grade']->meta_type);
     $this->assertSame('N', $columns['percentfloat']->meta_type);
     $this->assertSame('I', $columns['userid']->meta_type);
     // Some defaults.
     $this->assertTrue($columns['course']->has_default);
     $this->assertEquals(0, $columns['course']->default_value);
     $this->assertTrue($columns['name']->has_default);
     $this->assertSame('Moodle', $columns['name']->default_value);
     $this->assertTrue($columns['secondname']->has_default);
     $this->assertSame('', $columns['secondname']->default_value);
     $this->assertTrue($columns['thirdname']->has_default);
     $this->assertSame('', $columns['thirdname']->default_value);
     $this->assertTrue($columns['percentfloat']->has_default);
     $this->assertEquals(99.90000000000001, $columns['percentfloat']->default_value);
     $this->assertTrue($columns['userid']->has_default);
     $this->assertEquals(0, $columns['userid']->default_value);
     // Basic get_indexes() test.
     $indexes = $DB->get_indexes('test_table1');
     $courseindex = reset($indexes);
     $this->assertEquals(1, $courseindex['unique']);
     $this->assertSame('course', $courseindex['columns'][0]);
     // Check sequence returns 1 for first insert.
     $rec = (object) array('course' => 10, 'secondname' => 'not important', 'intro' => 'not important');
     $this->assertSame(1, $DB->insert_record('test_table1', $rec));
     // Check defined defaults are working ok.
     $dbrec = $DB->get_record('test_table1', array('id' => 1));
     $this->assertSame('Moodle', $dbrec->name);
     $this->assertSame('', $dbrec->thirdname);
     // Check exceptions if multiple R columns.
     $table = new xmldb_table('test_table2');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('rid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('primaryx', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('ddl_exception', $e);
     }
     // Check exceptions missing primary key on R column.
     $table = new xmldb_table('test_table2');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('ddl_exception', $e);
     }
     // Long table name names - the largest allowed.
     $table = new xmldb_table('test_table0123456789_____xyz');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '2');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     $dbman->create_table($table);
     $this->assertTrue($dbman->table_exists($table));
     $dbman->drop_table($table);
     // Table name is too long.
     $table = new xmldb_table('test_table0123456789_____xyz9');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '2');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (moodle_exception $e) {
//.........这里部分代码省略.........
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:101,代码来源:ddl_test.php

示例7: 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;
     // Do the job, setting result as needed
     // Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $dirpath;
     // Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir = $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir = $XMLDB->editeddirs[$dirpath];
         $structure = $editeddir->xml_file->getStructure();
     }
     // If the changeme table exists, just get it and continue
     $changeme_exists = false;
     if ($tables = $structure->getTables()) {
         if ($table = $structure->getTable('changeme')) {
             $changeme_exists = true;
         }
     }
     if (!$changeme_exists) {
         // Lets create the table
         $field = new xmldb_field('id');
         $field->setType(XMLDB_TYPE_INTEGER);
         $field->setLength(10);
         $field->setNotNull(true);
         $field->setSequence(true);
         $field->setLoaded(true);
         $field->setChanged(true);
         $key = new xmldb_key('primary');
         $key->setType(XMLDB_KEY_PRIMARY);
         $key->setFields(array('id'));
         $key->setLoaded(true);
         $key->setChanged(true);
         $table = new xmldb_table('changeme');
         $table->setComment('Default comment for the table, please edit me');
         $table->addField($field);
         $table->addKey($key);
         // Finally, add the whole retrofitted table to the structure
         // in the place specified
         $structure->addTable($table);
     }
     // Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:64,代码来源:new_table.class.php

示例8: test_create_table

 /**
  * Test behaviour of create_table()
  */
 public function test_create_table()
 {
     $DB = $this->tdb;
     // do not use global $DB!
     $dbman = $this->tdb->get_manager();
     // create table
     $table = $this->tables['test_table1'];
     $dbman->create_table($table);
     $this->assertTrue($dbman->table_exists($table));
     // basic get_tables() test
     $tables = $DB->get_tables();
     $this->assertTrue(array_key_exists('test_table1', $tables));
     // basic get_columns() tests
     $columns = $DB->get_columns('test_table1');
     $this->assertEquals($columns['id']->meta_type, 'R');
     $this->assertEquals($columns['course']->meta_type, 'I');
     $this->assertEquals($columns['name']->meta_type, 'C');
     $this->assertEquals($columns['secondname']->meta_type, 'C');
     $this->assertEquals($columns['thirdname']->meta_type, 'C');
     $this->assertEquals($columns['intro']->meta_type, 'X');
     $this->assertEquals($columns['avatar']->meta_type, 'B');
     $this->assertEquals($columns['grade']->meta_type, 'N');
     $this->assertEquals($columns['percentfloat']->meta_type, 'N');
     $this->assertEquals($columns['userid']->meta_type, 'I');
     // some defaults
     $this->assertTrue($columns['course']->has_default);
     $this->assertEquals($columns['course']->default_value, 0);
     $this->assertTrue($columns['name']->has_default);
     $this->assertEquals($columns['name']->default_value, 'Moodle');
     $this->assertTrue($columns['secondname']->has_default);
     $this->assertEquals($columns['secondname']->default_value, '');
     $this->assertTrue($columns['thirdname']->has_default);
     $this->assertEquals($columns['thirdname']->default_value, '');
     $this->assertTrue($columns['percentfloat']->has_default);
     $this->assertEquals($columns['percentfloat']->default_value, 99.90000000000001);
     $this->assertTrue($columns['userid']->has_default);
     $this->assertEquals($columns['userid']->default_value, 0);
     // basic get_indexes() test
     $indexes = $DB->get_indexes('test_table1');
     $courseindex = reset($indexes);
     $this->assertEquals($courseindex['unique'], 1);
     $this->assertEquals($courseindex['columns'][0], 'course');
     // check sequence returns 1 for first insert
     $rec = (object) array('course' => 10, 'secondname' => 'not important', 'intro' => 'not important');
     $this->assertSame($DB->insert_record('test_table1', $rec), 1);
     // check defined defaults are working ok
     $dbrec = $DB->get_record('test_table1', array('id' => 1));
     $this->assertEquals($dbrec->name, 'Moodle');
     $this->assertEquals($dbrec->thirdname, '');
     // check exceptions if multiple R columns
     $table = new xmldb_table('test_table2');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('rid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('primaryx', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (Exception $e) {
         $this->assertTrue($e instanceof ddl_exception);
     }
     // check exceptions missing primary key on R column
     $table = new xmldb_table('test_table2');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (Exception $e) {
         $this->assertTrue($e instanceof ddl_exception);
     }
     // long table name names - the largest allowed
     $table = new xmldb_table('test_table0123456789_____xyz');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '2');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     $dbman->create_table($table);
     $this->assertTrue($dbman->table_exists($table));
     $dbman->drop_table($table);
     // table name is too long
     $table = new xmldb_table('test_table0123456789_____xyz9');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '2');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->setComment("This is a test'n drop table. You can drop it safely");
     $this->tables[$table->getName()] = $table;
     try {
         $dbman->create_table($table);
         $this->fail('Exception expected');
     } catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:numbas,项目名称:moodle,代码行数:101,代码来源:ddl_test.php

示例9: test_create_table

    /**
     * Test behaviour of create_table()
     */
    public function test_create_table() {
        $DB = $this->tdb; // do not use global $DB!
        $dbman = $this->tdb->get_manager();

        // create table
        $table = $this->tables['test_table1'];

        $dbman->create_table($table);
        $this->assertTrue($dbman->table_exists($table));

        // basic get_tables() test
        $tables = $DB->get_tables();
        $this->assertTrue(array_key_exists('test_table1', $tables));

        // basic get_columns() tests
        $columns = $DB->get_columns('test_table1');
        $this->assertEqual($columns['id']->meta_type, 'R');
        $this->assertEqual($columns['course']->meta_type, 'I');
        $this->assertEqual($columns['name']->meta_type, 'C');
        $this->assertEqual($columns['secondname']->meta_type, 'C');
        $this->assertEqual($columns['thirdname']->meta_type, 'C');
        $this->assertEqual($columns['intro']->meta_type, 'X');
        $this->assertEqual($columns['avatar']->meta_type, 'B');
        $this->assertEqual($columns['grade']->meta_type, 'N');
        $this->assertEqual($columns['percentfloat']->meta_type, 'N');
        $this->assertEqual($columns['userid']->meta_type, 'I');
        // some defaults
        $this->assertTrue($columns['course']->has_default);
        $this->assertEqual($columns['course']->default_value, 0);
        $this->assertTrue($columns['name']->has_default);
        $this->assertEqual($columns['name']->default_value, 'Moodle');
        $this->assertTrue($columns['secondname']->has_default);
        $this->assertEqual($columns['secondname']->default_value, '');
        $this->assertTrue($columns['thirdname']->has_default);
        $this->assertEqual($columns['thirdname']->default_value, '');
        $this->assertTrue($columns['percentfloat']->has_default);
        $this->assertEqual($columns['percentfloat']->default_value, 99.9);
        $this->assertTrue($columns['userid']->has_default);
        $this->assertEqual($columns['userid']->default_value, 0);

        // basic get_indexes() test
        $indexes = $DB->get_indexes('test_table1');
        $courseindex = reset($indexes);
        $this->assertEqual($courseindex['unique'], 1);
        $this->assertEqual($courseindex['columns'][0], 'course');

        // check sequence returns 1 for first insert
        $rec = (object)array(
                'course'     => 10,
                'secondname' => 'not important',
                'intro'      => 'not important');
        $this->assertIdentical($DB->insert_record('test_table1', $rec), 1);

        // check defined defaults are working ok
        $dbrec = $DB->get_record('test_table1', array('id' => 1));
        $this->assertEqual($dbrec->name, 'Moodle');
        $this->assertEqual($dbrec->thirdname, '');

        // check exceptions if multiple R columns
        $table = new xmldb_table ('test_table2');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('rid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->add_key('primaryx', XMLDB_KEY_PRIMARY, array('id'));
        $table->setComment("This is a test'n drop table. You can drop it safely");

        $this->tables[$table->getName()] = $table;

        try {
            $dbman->create_table($table);
            $this->fail('Exception expected');
        } catch (Exception $e) {
            $this->assertTrue($e instanceof ddl_exception);
        }

        // check exceptions missing primary key on R column
        $table = new xmldb_table ('test_table2');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
        $table->setComment("This is a test'n drop table. You can drop it safely");

        $this->tables[$table->getName()] = $table;

        try {
            $dbman->create_table($table);
            $this->fail('Exception expected');
        } catch (Exception $e) {
            $this->assertTrue($e instanceof ddl_exception);
        }

    }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:95,代码来源:testddl.php

示例10: xmldb_facetoface_upgrade


//.........这里部分代码省略.........
            $badusers = $DB->count_records_sql($sql, $inparams);
            $fullzones = array_merge(array_keys($badzones), array_values($goodzones));
            $fullzones[] = 99;
            list($insql, $inparams) = $DB->get_in_or_equal($fullzones, SQL_PARAMS_QM, 'param', false);
            $sql = "SELECT count(id) from {user} WHERE timezone $insql";
            $unknownusercount = $DB->count_records_sql($sql, $inparams);

            if ($badusers > 0 || $unknownusercount > 0) {
                //some users have bad timezones set
                //output a notice and direct to the new admin tool
                $info = get_string('badusertimezonemessage', 'mod_facetoface');
                echo $OUTPUT->notification($info, 'notifynotice');
            } else {
                //only if the site timezone is sensible AND no users have bad zones
                $sql = 'UPDATE {facetoface_sessions_dates} SET sessiontimezone = ?';
                $DB->execute($sql, array($default));
            }
        }
        //sessions created before this upgrade may still need fixing
        $sql = "SELECT count(id) from {facetoface_sessions_dates} WHERE sessiontimezone IS NULL OR " . $DB->sql_compare_text('sessiontimezone', 255) . " = ?";
        $unfixedsessions = $DB->count_records_sql($sql, array(''));
        if ($unfixedsessions > 0) {
            $info = get_string('timezoneupgradeinfomessage', 'facetoface');
            echo $OUTPUT->notification($info, 'notifynotice');
        }
        upgrade_mod_savepoint(true, 2013013000, 'facetoface');
    }
    if ($oldversion < 2013013001) {

        // Define table facetoface_notification_tpl to be created
        $table = new xmldb_table('facetoface_notification_tpl');

        // Set up the comment for the notification templates table.
        $table->setComment('Face-to-face notification templates');

        // Adding fields to table facetoface_notification_tpl
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('body', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null);
        $table->add_field('managerprefix', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
        $table->add_field('status', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');

        // Adding keys to table facetoface_notification_tpl
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));

        // Adding indexes to table facetoface_notification_tpl
        $table->add_index('title', XMLDB_INDEX_UNIQUE, array('title'));
        $table->add_index('status', XMLDB_INDEX_NOTUNIQUE, array('status'));

        // Launch create table for facetoface_notification_tpl
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }

        upgrade_mod_savepoint(true, 2013013001, 'facetoface');
    }

    if ($result && $oldversion < 2013013002) {

        // Define table facetoface_notification to be created
        $table = new xmldb_table('facetoface_notification');

        // Set up the comment for the facetoface notification table.
        $table->setComment('Facetoface notifications');

        // Adding fields to table facetoface_notification
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:67,代码来源:upgrade.php

示例11: 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 $XMLDB, $DB, $CFG;
     $dbman = $DB->get_manager();
     $gen = $dbman->generator;
     $dbfamily = $DB->get_dbfamily();
     /// 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 xmldb_table('testtable');
     if ($dbman->table_exists($table)) {
         $dbman->drop_table($table);
     }
     $table = new xmldb_table('anothertest');
     if ($dbman->table_exists($table)) {
         $dbman->drop_table($table);
     }
     $table = new xmldb_table('newnameforthetable');
     if ($dbman->table_exists($table)) {
         $dbman->drop_table($table);
     }
     /// 1st test. Complete table creation.
     $table = new xmldb_table('testtable');
     $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
     $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'general');
     $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null);
     $table->add_field('intro', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
     $table->add_field('logo', XMLDB_TYPE_BINARY, 'big', null, XMLDB_NOTNULL, null);
     $table->add_field('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
     $table->add_field('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
     $table->add_field('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,0', XMLDB_UNSIGNED, null, null, null);
     $table->add_field('percent', XMLDB_TYPE_NUMBER, '5,2', null, null, null, null);
     $table->add_field('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_field('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
     $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
     $table->add_key('type-name', XMLDB_KEY_UNIQUE, array('type', 'name'));
     $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
     $table->add_index('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 = $gen->getCreateTableSQL($table);
     try {
         $dbman->create_table($table);
         $test->status = true;
     } catch (moodle_exception $e) {
         $test->status = false;
         $test->error = $DB->get_last_error() . "\n" . $e;
     }
     $tests['create table'] = $test;
     /// 2nd test. drop table
     if ($test->status) {
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $gen->getDropTableSQL($table);
         try {
             $dbman->drop_table($table);
             $test->status = true;
         } catch (moodle_exception $e) {
             $test->status = false;
             $test->error = $DB->get_last_error() . "\n" . $e;
         }
         $tests['drop table'] = $test;
     }
     /// 3rd test. creating another, smaller table
     if ($test->status) {
         $table = new xmldb_table('anothertest');
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
         $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
         $table->add_field('name', XMLDB_TYPE_CHAR, '30', null, null, null, 'Moodle');
         $table->add_field('secondname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null);
         $table->add_field('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
         $table->add_field('avatar', XMLDB_TYPE_BINARY, 'medium', null, null, null, null);
         $table->add_field('grade', XMLDB_TYPE_NUMBER, '20,10', null, null, null);
//.........这里部分代码省略.........
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:test.class.php

示例12: xmldb_core_install


//.........这里部分代码省略.........

    // Adding fields to table 'badge'
    $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
    $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'id');
    $table->add_field('description', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
    $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'description');
    $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timecreated');
    $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'timemodified');
    $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'usercreated');
    $table->add_field('issuername', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'usermodified');
    $table->add_field('issuerurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'issuername');
    $table->add_field('issuercontact', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'issuerurl');
    $table->add_field('expiredate', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'issuercontact');
    $table->add_field('expireperiod', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'expiredate');
    $table->add_field('type', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'expireperiod');
    $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'type');
    $table->add_field('message', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'courseid');
    $table->add_field('messagesubject', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'message');
    $table->add_field('attachment', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'messagesubject');
    $table->add_field('notification', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'attachment');
    $table->add_field('status', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'notification');
    $table->add_field('nextcron', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'status');

    // Adding keys to table 'badge'
    $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->add_key('fk_courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
    $table->add_key('fk_usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
    $table->add_key('fk_usercreated', XMLDB_KEY_FOREIGN, array('usercreated'), 'user', array('id'));

    // Adding indexes to table 'badge'
    $table->add_index('type', XMLDB_INDEX_NOTUNIQUE, array('type'));

    // Set the comment for the table 'badge'.
    $table->setComment('Defines badge');

    // Conditionally launch create table for 'badge'
    if (!$dbman->table_exists($table)) {
        $dbman->create_table($table);
    }

    // Define table 'badge_criteria' to be created
    $table = new xmldb_table('badge_criteria');

    // Adding fields to table 'badge_criteria'
    $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
    $table->add_field('badgeid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
    $table->add_field('criteriatype', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'badgeid');
    $table->add_field('method', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'criteriatype');

    // Adding keys to table 'badge_criteria'
    $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->add_key('fk_badgeid', XMLDB_KEY_FOREIGN, array('badgeid'), 'badge', array('id'));

    // Adding indexes to table 'badge_criteria'
    $table->add_index('criteriatype', XMLDB_INDEX_NOTUNIQUE, array('criteriatype'));
    $table->add_index('badgecriteriatype', XMLDB_INDEX_UNIQUE, array('badgeid', 'criteriatype'));

    // Set the comment for the table 'badge_criteria'.
    $table->setComment('Defines criteria for issuing badges');

    // Conditionally launch create table for 'badge_criteria'
    if (!$dbman->table_exists($table)) {
        $dbman->create_table($table);
    }

    // Define table 'badge_criteria_param' to be created
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:67,代码来源:install.php


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