本文整理汇总了PHP中backup_nested_element::set_source_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP backup_nested_element::set_source_sql方法的具体用法?PHP backup_nested_element::set_source_sql怎么用?PHP backup_nested_element::set_source_sql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backup_nested_element
的用法示例。
在下文中一共展示了backup_nested_element::set_source_sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define_structure
protected function define_structure()
{
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated
$rcontent = new backup_nested_element('rcontent', array('id'), array('course', 'name', 'intro', 'introformat', 'levelid', 'whatgrade', 'popup', 'popup_options', 'frame', 'width', 'height', 'timecreated', 'timemodified', 'levelcode', 'isbn', 'unitcode', 'activitycode'));
$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', array('id'), array('userid', 'rcontentid', 'grade', 'mingrade', 'maxgrade', 'attempt', 'maxattempts', 'starttime', 'totaltime', 'maxtotaltime', 'status', 'comments', 'urlviewresults', 'sumweights', 'timecreated', 'timemodified', 'unitcode', 'activitycode'));
$grades_details = new backup_nested_element('grades_details');
$grade_detail = new backup_nested_element('grade_detail', array('id'), array('userid', 'rcontentid', 'code', 'typeid', 'description', 'grade', 'mingrade', 'maxgrade', 'starttime', 'totaltime', 'maxtotaltime', 'attempt', 'maxattempts', 'weight', 'urlviewresults', 'timecreated', 'timemodified', 'unitcode', 'activitycode'));
$track_credentials = new backup_nested_element('track_credentials');
$track_credential = new backup_nested_element('track_credential', array('id'), array('username', 'password', 'publisherid', 'timecreated', 'timemodified'));
// Build the tree
$rcontent->add_child($grades);
$grades->add_child($grade);
$grade->add_child($grades_details);
$grades_details->add_child($grade_detail);
$rcontent->add_child($track_credentials);
$track_credentials->add_child($track_credential);
// Define sources
//$rcontent->set_source_table('rcontent', array('id' => backup::VAR_ACTIVITYID));
$rcontent->set_source_sql('SELECT rc.*,rlevel.code as levelcode, rcb.isbn as isbn, unit.code as unitcode, activity.code as activitycode
FROM {rcontent} rc
LEFT outer JOIN {rcommon_level} rlevel on rlevel.id=rc.levelid
LEFT outer JOIN {rcommon_books} rcb on rcb.id=rc.bookid and rcb.levelid=rc.levelid
LEFT outer JOIN {rcommon_books_units} unit on unit.id=rc.unitid and unit.bookid=rc.bookid
LEFT outer JOIN {rcommon_books_activities} activity on activity.id=rc.activityid and activity.bookid=rc.bookid and activity.unitid = rc.unitid
WHERE rc.id = ?', array(backup::VAR_ACTIVITYID));
// Use set_source_sql for other calls as set_source_table returns records in reverse order
// and order is important for several rcontent fields - esp rcontent_scoes.
$grade->set_source_sql('
SELECT rg.*, unit.code as unitcode, activity.code as activitycode
FROM {rcontent_grades} rg
INNER JOIN {rcontent} rc ON rc.id=rg.rcontentid
LEFT outer JOIN {rcommon_books_units} unit on unit.id=rc.unitid and unit.bookid=rc.bookid
LEFT outer JOIN {rcommon_books_activities} activity on activity.id=rc.activityid and activity.bookid=rc.bookid and activity.unitid = rc.unitid
WHERE rg.rcontentid = :rcontent
ORDER BY rg.id', array('rcontent' => backup::VAR_PARENTID));
$grade_detail->set_source_sql('
SELECT rc.*, unit.code as unitcode, activity.code as activitycode
FROM {rcontent_grades_details} rg
INNER JOIN {rcontent} rc ON rc.id=rg.rcontentid
LEFT outer JOIN {rcommon_books_units} unit on unit.id=rc.unitid and unit.bookid=rc.bookid
LEFT outer JOIN {rcommon_books_activities} activity on activity.id=rc.activityid and activity.bookid=rc.bookid and activity.unitid = rc.unitid
WHERE rg.rcontentid = :rcontent
ORDER BY rg.id', array('rcontent' => backup::VAR_PARENTID));
$track_credentials->set_source_sql('
SELECT *
FROM {rcontent_track_credentials}
ORDER BY id', array());
// Define id annotations
$grade->annotate_ids('user', 'userid');
$grade_detail->annotate_ids('user', 'userid');
// Define file annotations
$rcontent->annotate_files('mod_rcontent', 'intro', null);
// This file area hasn't itemid
// Return the root element (rcontent), wrapped into standard activity structure
return $this->prepare_activity_structure($rcontent);
}
示例2: define_structure
/**
* Define the structure for the links block.
* @return void
*/
protected function define_structure()
{
// Define each element separated.
$link = new backup_nested_element('link', null, array('id', 'linktext', 'url', 'notes', 'defaultshow', 'department'));
// Define sources.
$link->set_source_sql("SELECT * FROM {block_links}", array());
// Annotations (none).
// Return the root element (links), wrapped into standard block structure.
return $this->prepare_block_structure($link);
}
示例3: define_structure
protected function define_structure()
{
// Define each element separated
$module = new backup_nested_element('module', array('id', 'version'), array('modulename', 'sectionid', 'sectionnumber', 'idnumber', 'added', 'score', 'indent', 'visible', 'visibleold', 'groupmode', 'groupingid', 'groupmembersonly', 'completion', 'completiongradeitemnumber', 'completionview', 'completionexpected', 'availablefrom', 'availableuntil', 'showavailability'));
$availinfo = new backup_nested_element('availability_info');
$availability = new backup_nested_element('availability', array('id'), array('sourcecmid', 'requiredcompletion', 'gradeitemid', 'grademin', 'grademax'));
// Define the tree
$module->add_child($availinfo);
$availinfo->add_child($availability);
// Set the sources
$module->set_source_sql('
SELECT cm.*, m.version, m.name AS modulename, s.id AS sectionid, s.section AS sectionnumber
FROM {course_modules} cm
JOIN {modules} m ON m.id = cm.module
JOIN {course_sections} s ON s.id = cm.section
WHERE cm.id = ?', array(backup::VAR_MODID));
$availability->set_source_table('course_modules_availability', array('coursemoduleid' => backup::VAR_MODID));
// Define annotations
$module->annotate_ids('grouping', 'groupingid');
// Return the root element ($module)
return $module;
}