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


PHP xmldb_field::setUnsigned方法代码示例

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


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

示例1: 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->setUnsigned(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:raymondAntonio,项目名称:moodle,代码行数:65,代码来源:new_table.class.php

示例2: invoke


//.........这里部分代码省略.........
         if (!(empty($default) || is_numeric($default) && !empty($default))) {
             $errors[] = $this->str['defaultincorrect'];
         }
     }
     /// Char checks
     if ($type == XMLDB_TYPE_CHAR) {
         if (!(is_numeric($length) && !empty($length) && intval($length) == floatval($length) && $length > 0 && $length <= 255)) {
             $errors[] = $this->str['charincorrectlength'];
         }
         if ($default !== NULL && $default !== '') {
             if (substr($default, 0, 1) == "'" || substr($default, -1, 1) == "'") {
                 $errors[] = $this->str['defaultincorrect'];
             }
         }
     }
     /// Text checks
     if ($type == XMLDB_TYPE_TEXT) {
         if ($length != 'small' && $length != 'medium' && $length != 'big') {
             $errors[] = $this->str['textincorrectlength'];
         }
         if ($default !== NULL && $default !== '') {
             if (substr($default, 0, 1) == "'" || substr($default, -1, 1) == "'") {
                 $errors[] = $this->str['defaultincorrect'];
             }
         }
     }
     /// Binary checks
     if ($type == XMLDB_TYPE_BINARY) {
         if ($length != 'small' && $length != 'medium' && $length != 'big') {
             $errors[] = $this->str['binaryincorrectlength'];
         }
     }
     if (!empty($errors)) {
         $tempfield = new xmldb_field($name);
         $tempfield->setType($type);
         $tempfield->setLength($length);
         $tempfield->setDecimals($decimals);
         $tempfield->setUnsigned($unsigned);
         $tempfield->setNotNull($notnull);
         $tempfield->setSequence($sequence);
         $tempfield->setDefault($default);
         /// Prepare the output
         $site = get_site();
         $navlinks = array();
         $navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc');
         $navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header("{$site->shortname}: XMLDB", "{$site->fullname}", $navigation);
         notice('<p>' . implode(', ', $errors) . '</p>
                  <p>' . $tempfield->readableInfo() . '</p>', 'index.php?action=edit_field&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
         die;
         /// re-die :-P
     }
     /// Continue if we aren't under errors
     if (empty($errors)) {
         /// If there is one name change, do it, changing the prev and next
         /// atributes of the adjacent fields
         if ($fieldparam != $name) {
             $field->setName($name);
             if ($field->getPrevious()) {
                 $prev =& $table->getField($field->getPrevious());
                 $prev->setNext($name);
                 $prev->setChanged(true);
             }
             if ($field->getNext()) {
                 $next =& $table->getField($field->getNext());
                 $next->setPrevious($name);
                 $next->setChanged(true);
             }
         }
         /// Set comment
         $field->setComment($comment);
         /// Set the rest of fields
         $field->setType($type);
         $field->setLength($length);
         $field->setDecimals($decimals);
         $field->setUnsigned($unsigned);
         $field->setNotNull($notnull);
         $field->setSequence($sequence);
         $field->setDefault($default);
         /// If the hash has changed from the old one, change the version
         /// and mark the structure as changed
         $field->calculateHash(true);
         if ($oldhash != $field->getHash()) {
             $field->setChanged(true);
             $table->setChanged(true);
             /// Recalculate the structure hash
             $structure->calculateHash(true);
             $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
             /// Mark as changed
             $structure->setChanged(true);
         }
         /// Launch postaction if exists (leave this here!)
         if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:edit_field_save.class.php

示例3: xmldb_questionnaire_upgrade


//.........这里部分代码省略.........
            $capsubmit = 'mod/questionnaire:submit';
            foreach ($rs as $questionnaire) {
                $context = get_context_instance(CONTEXT_MODULE, $questionnaire->cmid);
                // Convert questionnaires with resp_eligible = 'all' so that students & teachers have view and submit.
                if ($questionnaire->resp_eligible == 'all') {
                    assign_capability($capsubmit, CAP_ALLOW, $editteacherroleid, $context->id, true);
                    assign_capability($capsubmit, CAP_ALLOW, $teacherroleid, $context->id, true);
                    // Convert questionnaires with resp_eligible = 'students' so that just students have view and submit.
                } else {
                    if ($questionnaire->resp_eligible == 'teachers') {
                        assign_capability($capsubmit, CAP_ALLOW, $editteacherroleid, $context->id, true);
                        assign_capability($capsubmit, CAP_ALLOW, $teacherroleid, $context->id, true);
                        assign_capability($capview, CAP_PREVENT, $studentroleid, $context->id, true);
                        assign_capability($capsubmit, CAP_PREVENT, $studentroleid, $context->id, true);
                    }
                }
            }
            $rs->close();
        }
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008031904, 'questionnaire');
    }
    if ($oldversion < 2008031905) {
        $table = new xmldb_table('questionnaire_survey');
        $field = new xmldb_field('changed');
        $dbman->drop_field($table, $field);
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008031905, 'questionnaire');
    }
    if ($oldversion < 2008031906) {
        $table = new xmldb_table('questionnaire_response_rank');
        $field = new xmldb_field('rank');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null, null, '0', 'choice_id');
        $field->setUnsigned(false);
        $dbman->change_field_unsigned($table, $field);
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008031906, 'questionnaire');
    }
    if ($oldversion < 2008060401) {
        $table = new xmldb_table('questionnaire_question');
        $field = new xmldb_field('name');
        $field->set_attributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'survey_id');
        $field->setNotnull(false);
        $dbman->change_field_notnull($table, $field);
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008060401, 'questionnaire');
    }
    if ($oldversion < 2008070702) {
        $table = new xmldb_table('questionnaire_question_type');
        $field = new xmldb_field('response_table');
        $field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null, 'has_choices');
        $field->setNotnull(false);
        $dbman->change_field_notnull($table, $field);
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008070702, 'questionnaire');
    }
    if ($oldversion < 2008070703) {
        $table = new xmldb_table('questionnaire_resp_multiple');
        $index = new xmldb_index('response_question');
        $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('response_id', 'question_id', 'choice_id'));
        if (!$dbman->index_exists($table, $index)) {
            $dbman->add_index($table, $index);
        }
        // Questionnaire savepoint reached.
        upgrade_mod_savepoint(true, 2008070703, 'questionnaire');
    }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:67,代码来源:upgrade.php


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