From: skodak Date: Mon, 2 Jun 2008 21:52:27 +0000 (+0000) Subject: MDL-14679 converted some delete_records X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8618fd2aebef4447b2fd02a87db016b778cdaf28;p=moodle.git MDL-14679 converted some delete_records --- diff --git a/admin/health.php b/admin/health.php index 14db41b608..e02e65a3c6 100644 --- a/admin/health.php +++ b/admin/health.php @@ -518,10 +518,10 @@ class problem_000011 extends problem_base { } } 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 { diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index da71a863f5..8d1e0d89d8 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -475,7 +475,7 @@ class auth_plugin_mnet extends auth_plugin_base { * @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; @@ -490,9 +490,7 @@ class auth_plugin_mnet extends auth_plugin_base { } 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; } diff --git a/blog/edit.php b/blog/edit.php index b92ec96da1..a2761100f6 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -156,7 +156,7 @@ function do_delete($post) { 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); @@ -215,8 +215,8 @@ function do_edit($post, $blogeditform) { 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); diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php index 8ae16f6a6a..2000a060c9 100644 --- a/filter/algebra/algebradebug.php +++ b/filter/algebra/algebradebug.php @@ -46,7 +46,7 @@ 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 { diff --git a/filter/tex/lib.php b/filter/tex/lib.php index f02fba5252..db6405bcd6 100644 --- a/filter/tex/lib.php +++ b/filter/tex/lib.php @@ -52,7 +52,7 @@ function tex_filter_get_cmd($pathname, $texexp) { * 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")) { @@ -65,8 +65,8 @@ function filter_tex_updatedcallback($name) { 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')); } ?> diff --git a/filter/tex/texdebug.php b/filter/tex/texdebug.php index 137659620c..b83c05a7a4 100644 --- a/filter/tex/texdebug.php +++ b/filter/tex/texdebug.php @@ -52,7 +52,7 @@ 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 { diff --git a/index.php b/index.php index 3bde1548e0..014d5c292d 100644 --- a/index.php +++ b/index.php @@ -140,7 +140,7 @@ 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 = ''; diff --git a/lib/blocklib.php b/lib/blocklib.php index 102486536f..ea947d9121 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1016,7 +1016,7 @@ function blocks_repopulate_page($page) { // 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 @@ -1420,7 +1420,7 @@ function upgrade_blocks_plugins($continueto) { 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(); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d454d76674..12f551258c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3700,12 +3700,12 @@ function reset_course_userdata($data) { } 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); } diff --git a/lib/weblib.php b/lib/weblib.php index 7b06ee782a..af9fe88812 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1583,9 +1583,9 @@ function text_format_name( $key ) { * @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); } diff --git a/tag/lib.php b/tag/lib.php index c1946bd48c..67aa9a64de 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -519,7 +519,7 @@ function tag_delete($tagids) { } // 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)); }