}
}
function solution() {
- global $CFG;
+ global $CFG, $DB;
if (optional_param('resetsesserrorcounter', 0, PARAM_BOOL)) {
if ($DB->get_field('config', 'name', array('name'=>'session_error_counter'))) {
- delete_records('config', 'name', 'session_error_counter');
+ $DB->delete_records('config', array('name'=>'session_error_counter'));
}
return 'Error counter was cleared.';
} else {
* @return bool
*/
function update_enrolments($username, $courses) {
- global $MNET_REMOTE_CLIENT, $CFG;
+ global $MNET_REMOTE_CLIENT, $CFG, $DB;
if (empty($username) || !is_array($courses)) {
return false;
}
if (empty($courses)) { // no courses? clear out quickly
- delete_records('mnet_enrol_assignments',
- 'hostid', (int)$MNET_REMOTE_CLIENT->id,
- 'userid', $userid);
+ $DB->delete_records('mnet_enrol_assignments', array('hostid'=>$MNET_REMOTE_CLIENT->id, 'userid'=>$userid));
return true;
}
global $returnurl, $DB;
$status = $DB->delete_records('post', array('id'=>$post->id));
- //$status = delete_records('blog_tag_instance', 'entryid', $post->id) and $status;
+ //$status = $DB->delete_records('blog_tag_instance', array('entryid'=>$post->id)) and $status;
tag_set('post', $post->id, array());
blog_delete_old_attachments($post);
if ($DB->update_record('post', $post)) {
// delete all tags associated with this entry
- //delete_records('blog_tag_instance', 'entryid', $post->id);
- //delete_records('tag_instance', 'itemid', $post->id, 'itemtype', 'blog');
+ //$DB->delete_records('blog_tag_instance', array('entryid'=>$post->id));
+ //$DB->delete_records('tag_instance', array('itemid'=>$post->id, 'itemtype'=>'blog'));
//untag_an_item('post', $post->id);
// add them back
add_tags_info($post->id);
if (strpos($query,'DeleteDB')) {
if ($texcache) {
$output = "Deleting DB cache_filters entry for $algebra\n";
- $result = delete_records("cache_filters","id",$texcache->id);
+ $result = $DB->delete_records("cache_filters", array("id"=>$texcache->id));
if ($result) {
$result = 1;
} else {
* Purge all caches when settings changed.
*/
function filter_tex_updatedcallback($name) {
- global $CFG;
+ global $CFG, $DB;
reset_text_filters_cache();
if (file_exists("$CFG->dataroot/filter/tex")) {
remove_dir("$CFG->dataroot/temp/latex");
}
- delete_records('cache_filters', 'filter', 'tex');
- delete_records('cache_filters', 'filter', 'algebra');
+ $DB->delete_records('cache_filters', array('filter'=>'tex'));
+ $DB->delete_records('cache_filters', array('filter'=>'algebra'));
}
?>
if ($action=='DeleteDB') {
if ($texcache) {
$output = "Deleting DB cache_filters entry for $texexp\n";
- $result = delete_records("cache_filters","id",$texcache->id);
+ $result = $DB->delete_records("cache_filters", array("id"=>$texcache->id));
if ($result) {
$result = 1;
} else {
if ($SITE->numsections > 0) {
if (!$section = $DB->get_record('course_sections', array('course'=>$SITE->id, 'section'=>1))) {
- delete_records('course_sections', 'course', $SITE->id, 'section', 1); // Just in case
+ $DB->delete_records('course_sections', array('course'=>$SITE->id, 'section'=>1)); // Just in case
$section->course = $SITE->id;
$section->section = 1;
$section->summary = '';
// indexed and the indexes match, so we can work straight away... but CAREFULLY!
// Ready to start creating block instances, but first drop any existing ones
- delete_records('block_instance', 'pageid', $page->get_id(), 'pagetype', $page->get_type());
+ $DB->delete_records('block_instance', array('pageid'=>$page->get_id(), 'pagetype'=>$page->get_type()));
// Here we slyly count $posblocks and NOT $positions. This can actually make a difference
// if the textual representation has undefined slots in the end. So we only work with as many
upgrade_log_start();
$page = page_create_object(PAGE_COURSE_VIEW, SITEID);
blocks_repopulate_page($page);
- delete_records('config', 'name', 'siteblocksadded');
+ $DB->delete_records('config', array('name'=>'siteblocksadded'));
}
upgrade_log_finish();
}
if (!empty($data->reset_logs)) {
- delete_records('log', 'course', $data->courseid);
+ $DB->delete_records('log', array('course'=>$data->courseid));
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletelogs'), 'error'=>false);
}
if (!empty($data->reset_events)) {
- delete_records('event', 'courseid', $data->courseid);
+ $DB->delete_records('event', array('courseid'=>$data->courseid));
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteevents', 'calendar'), 'error'=>false);
}
* @return void
*/
function reset_text_filters_cache() {
- global $CFG;
+ global $CFG, $DB;
- delete_records('cache_text');
+ $DB->delete_records('cache_text');
$purifdir = $CFG->dataroot.'/cache/htmlpurifier';
remove_dir($purifdir, true);
}
}
// only delete the main entry if there were no problems deleting all the
// instances - that (and the fact we won't often delete lots of tags)
- // is the reason for not using delete_records_select()
+ // is the reason for not using $DB->delete_records_select()
if ($DB->delete_records('tag_instance', array('tagid'=>$tagid)) ) {
$success &= (bool) $DB->delete_records('tag', array('id'=>$tagid));
}