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


PHP XMLDBField::setUnsigned方法代码示例

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


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

示例1: xmldb_questionnaire_upgrade


//.........这里部分代码省略.........
        $field = new XMLDBField('complete');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_response', 'complete', 'y', 'complete', 'Y');
        set_field('questionnaire_response', 'complete', 'n', 'complete', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'n');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_response_bool');
        $field = new XMLDBField('choice_id');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_response_bool', 'choice_id', 'y', 'choice_id', 'Y');
        set_field('questionnaire_response_bool', 'choice_id', 'n', 'choice_id', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'y');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_survey');
        $field = new XMLDBField('public');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_survey', 'public', 'y', 'public', 'Y');
        set_field('questionnaire_survey', 'public', 'n', 'public', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'y');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        /// Upgrade question_type table with corrected 'response_table' fields.
        set_field('questionnaire_question_type', 'response_table', 'resp_single', 'response_table', 'response_single');
        set_field('questionnaire_question_type', 'response_table', 'resp_multiple', 'response_table', 'response_multiple');
    }
    if ($oldversion < 2008031902) {
        $table = new XMLDBTable('questionnaire');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, true, false, false, null, 0, 'navigate');
        $result = $result && add_field($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_response');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, true, false, false, null, 0, 'complete');
        $result = $result && add_field($table, $field);
    }
    if ($oldversion < 2008031904) {
        $sql = "SELECT q.id, q.resp_eligible, q.resp_view, cm.id as cmid\n                FROM {$CFG->prefix}questionnaire q, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n                WHERE m.name='questionnaire' AND m.id=cm.module AND cm.instance=q.id";
        if ($rs = get_recordset_sql($sql)) {
            $studentroleid = get_field('role', 'id', 'shortname', 'student');
            $editteacherroleid = get_field('role', 'id', 'shortname', 'editingteacher');
            $teacherroleid = get_field('role', 'id', 'shortname', 'teacher');
            $capview = 'mod/questionnaire:view';
            $capsubmit = 'mod/questionnaire:submit';
            while ($questionnaire = rs_fetch_next_record($rs)) {
                $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 == 'students') {
                        /// This is the default; no changes necessary.
                        /// Convert questionnaires with resp_eligible = 'teachers' so just teachers 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($rs);
        }
    }
    if ($oldversion < 2008031905) {
        $table = new XMLDBTable('questionnaire_survey');
        $field = new XMLDBField('changed');
        $result = $result && drop_field($table, $field);
    }
    if ($oldversion < 2008031906) {
        $table = new XMLDBTable('questionnaire_response_rank');
        $field = new XMLDBField('rank');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null, null, '0', 'choice_id');
        $field->setUnsigned(false);
        $result &= change_field_unsigned($table, $field);
    }
    if ($oldversion < 2008060401) {
        $table = new XMLDBTable('questionnaire_question');
        $field = new XMLDBField('name');
        $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'survey_id');
        $field->setNotnull(false);
        $result &= change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:upgrade.php

示例2: invoke


//.........这里部分代码省略.........
                 $enumarr[$key] = trim($enumelement);
                 $enumelement = trim($enumelement);
                 /// Calculate needed length
                 $le = strlen(str_replace("'", '', $enumelement));
                 if ($le > $maxlength) {
                     $maxlength = $le;
                 }
                 /// Skip if under error
                 if ($enumerr) {
                     continue;
                 }
                 /// Look for quoted strings
                 if (substr($enumelement, 0, 1) != "'" || substr($enumelement, -1, 1) != "'") {
                     $enumerr = true;
                 }
             }
         } else {
             $enumerr = true;
         }
         if ($enumerr) {
             $errors[] = $this->str['enumvaluesincorrect'];
         } else {
             $enumvalues = $enumarr;
         }
         if ($length < $maxlength) {
             $errors[] = $this->str['wronglengthforenum'];
         }
     }
     if (!empty($errors)) {
         $tempfield = new XMLDBField($name);
         $tempfield->setType($type);
         $tempfield->setLength($length);
         $tempfield->setDecimals($decimals);
         $tempfield->setUnsigned($unsigned);
         $tempfield->setNotNull($notnull);
         $tempfield->setSequence($sequence);
         $tempfield->setEnum($enum);
         $tempfield->setEnumValues($enumvalues);
         $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(), '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);
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:67,代码来源:edit_field_save.class.php

示例3: 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 . stripslashes_safe($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();
     }
     /// ADD YOUR CODE HERE
     /// 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 XMLDBField('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 XMLDBKey('primary');
         $key->setType(XMLDB_KEY_PRIMARY);
         $key->setFields(array('id'));
         $key->setLoaded(true);
         $key->setChanged(true);
         $table = new XMLDBTable('changeme');
         $table->setComment('Default comment for the table, please edit me');
         $table->addField($field);
         $table->addKey($key);
         /// Finally, add the whole retroffited 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:BackupTheBerlios,项目名称:samouk-svn,代码行数:66,代码来源:new_table.class.php


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