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


PHP XMLDBField::setNotnull方法代码示例

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


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


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