本文整理汇总了PHP中backup_nested_element::get_counter方法的典型用法代码示例。如果您正苦于以下问题:PHP backup_nested_element::get_counter方法的具体用法?PHP backup_nested_element::get_counter怎么用?PHP backup_nested_element::get_counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backup_nested_element
的用法示例。
在下文中一共展示了backup_nested_element::get_counter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
//.........这里部分代码省略.........
$dupetest4->set_source_array(array((object) array('field1' => '4', 'field2' => 4)));
// 1 object array
// Define some aliases
$rating->set_source_alias('rating', 'post_rating');
// Map the 'rating' value from DB to 'post_rating' final element
// Mark to detect files of type 'forum_intro' in forum (and not item id)
$forum->annotate_files('mod_forum', 'intro', null);
// Mark to detect file of type 'forum_post' and 'forum_attachment' in post (with itemid being post->id)
$post->annotate_files('mod_forum', 'post', 'id');
$post->annotate_files('mod_forum', 'attachment', 'id');
// Mark various elements to be annotated
$discussion->annotate_ids('user1', 'userid');
$post->annotate_ids('forum_post', 'id');
$rating->annotate_ids('user2', 'userid');
$rating->annotate_ids('forum_post', 'itemid');
// Create the backup_ids_temp table
backup_controller_dbops::create_backup_ids_temp_table($backupid);
// Instantiate in memory xml output
$xo = new memory_xml_output();
// Instantiate xml_writer and start it
$xw = new xml_writer($xo);
$xw->start();
// Instantiate the backup processor
$processor = new backup_structure_processor($xw);
// Set some variables
$processor->set_var(backup::VAR_ACTIVITYID, $this->forumid);
$processor->set_var(backup::VAR_BACKUPID, $backupid);
$processor->set_var(backup::VAR_CONTEXTID, $this->contextid);
// Process the backup structure with the backup processor
$forum->process($processor);
// Stop the xml_writer
$xw->stop();
// Check various counters
$this->assertEquals($forum->get_counter(), $DB->count_records('forum'));
$this->assertEquals($discussion->get_counter(), $DB->count_records('forum_discussions'));
$this->assertEquals($rating->get_counter(), $DB->count_records('rating'));
$this->assertEquals($read->get_counter(), $DB->count_records('forum_read'));
$this->assertEquals($inventeds->get_counter(), 2);
// Array
// Perform some validations with the generated XML
$dom = new DomDocument();
$dom->loadXML($xo->get_allcontents());
$xpath = new DOMXPath($dom);
// Some more counters
$query = '/forum/discussions/discussion/posts/post';
$posts = $xpath->query($query);
$this->assertEquals($posts->length, $DB->count_records('forum_posts'));
$query = '/forum/invented_elements/invented';
$inventeds = $xpath->query($query);
$this->assertEquals($inventeds->length, 2 * 2);
// Check ratings information against DB
$ratings = $dom->getElementsByTagName('rating');
$this->assertEquals($ratings->length, $DB->count_records('rating'));
foreach ($ratings as $rating) {
$ratarr = array();
$ratarr['id'] = $rating->getAttribute('id');
foreach ($rating->childNodes as $node) {
if ($node->nodeType != XML_TEXT_NODE) {
$ratarr[$node->nodeName] = $node->nodeValue;
}
}
$this->assertEquals($ratarr['userid'], $DB->get_field('rating', 'userid', array('id' => $ratarr['id'])));
$this->assertEquals($ratarr['itemid'], $DB->get_field('rating', 'itemid', array('id' => $ratarr['id'])));
$this->assertEquals($ratarr['post_rating'], $DB->get_field('rating', 'rating', array('id' => $ratarr['id'])));
}
// Check forum has "blockeperiod" with value 0 (was declared by object instead of name)