MDL-14679 converted some delete_records

This commit is contained in:
skodak
2008-06-02 21:52:27 +00:00
parent c7da43571b
commit 8618fd2aeb
11 changed files with 20 additions and 22 deletions
+2 -2
View File
@@ -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 {
+2 -4
View File
@@ -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;
}
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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 {
+3 -3
View File
@@ -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'));
}
?>
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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 = '';
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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));
}