]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 removed all instances of set_field_select()
authorskodak <skodak>
Sun, 1 Jun 2008 16:14:59 +0000 (16:14 +0000)
committerskodak <skodak>
Sun, 1 Jun 2008 16:14:59 +0000 (16:14 +0000)
course/lib.php
lib/dmllib.php
lib/dmllib_todo.php
lib/questionlib.php

index 9d3bb8de4a56785b672e5167dfa95fa0dbe117bf..315d984c1fa5564f4d64160af45f305a58aa5454 100644 (file)
@@ -1548,8 +1548,12 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
     global $COURSE, $DB;
 
     if ($clearonly) {
-        $courseselect = empty($courseid) ? "" : "id = $courseid";
-        set_field_select('course', 'modinfo', null, $courseselect);
+        if (empty($courseid)) {
+            $courseselect = array();
+        } else {
+            $courseselect = array('id'=>$courseid);
+        }
+        $DB->set_field('course', 'modinfo', null, $courseselect);
         // update cached global COURSE too ;-)
         if ($courseid == $COURSE->id) {
             $COURSE->modinfo = null; 
index f25711b7fdd55982c419329dbb59884353b998d2..8223084bd83ae56ac7ee9d7a92afc88d888625dd 100644 (file)
@@ -452,3 +452,7 @@ function records_to_menu($records, $field1, $field2) {
     error('records_to_menu() removed');
 }
 
+function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
+    error('set_field_select() removed');
+}
+
index f652e1fb72c7ebc24cc361ece1eec2617408c209..df03d15291415300c4633ed32e13aa17e4af513a 100644 (file)
@@ -728,81 +728,6 @@ function get_fieldset_sql($sql) {
     }
 }
 
-/**
- * Set a single field in every table row where the select statement evaluates to true.
- *
- * @uses $CFG
- * @uses $db
- * @param string $table The database table to be checked against.
- * @param string $newfield the field to set.
- * @param string $newvalue the value to set the field to.
- * @param string $select a fragment of SQL to be used in a where clause in the SQL call.
- * @param boolean $localcall Leave this set to false. (Should only be set to true by set_field.)
- * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
- */
-function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
-
-    global $db, $CFG;
-
-    if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; };
-
-    if (!$localcall) {
-        if ($select) {
-            $select = 'WHERE ' . $select;
-        }
-    }
-
-    $dataobject = new StdClass;
-    $dataobject->{$newfield} = $newvalue;
-    // Oracle DIRTY HACK -
-    if ($CFG->dbfamily == 'oracle') {
-        oracle_dirty_hack($table, $dataobject); // Convert object to the correct "empty" values for Oracle DB
-        $newvalue = $dataobject->{$newfield};
-    }
-    // End DIRTY HACK
-
-/// Under Oracle, MSSQL and PostgreSQL we have our own set field process
-/// If the field being updated is clob/blob, we use our alternate update here
-/// They will be updated later
-    if (($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql' || $CFG->dbfamily == 'postgres') && !empty($select)) {
-    /// Detect lobs
-        $foundclobs = array();
-        $foundblobs = array();
-        db_detect_lobs($table, $dataobject, $foundclobs, $foundblobs);
-    }
-
-/// Under Oracle, MSSQL and PostgreSQL, finally, update all the Clobs and Blobs present in the record
-/// if we know we have some of them in the query
-    if (($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql' || $CFG->dbfamily == 'postgres') && !empty($select) &&
-      (!empty($foundclobs) || !empty($foundblobs))) {
-        if (!db_update_lobs($table, $select, $foundclobs, $foundblobs)) {
-            return false; //Some error happened while updating LOBs
-        } else {
-            return true; //Everrything was ok
-        }
-    }
-
-/// NULL inserts - introduced in 1.9
-    if (is_null($newvalue)) {
-        $update = "$newfield = NULL";
-    } else {
-        $update = "$newfield = '$newvalue'";
-    }
-
-/// Arriving here, standard update
-    $sql = 'UPDATE '. $CFG->prefix . $table .' SET '.$update.' '.$select;
-    $rs = $db->Execute($sql);
-    if (!$rs) {
-        debugging($db->ErrorMsg() .'<br /><br />'. s($sql));
-        if (!empty($CFG->dblogerror)) {
-            $debug=array_shift(debug_backtrace());
-            error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT:  $sql");
-        }
-        return false;
-    }
-    return $rs;
-}
-
 /**
  * Delete one or more records from a table
  *
index 6b6d03dbde7d9ccf0dae6d56d4e02eb52dc99ddc..b538b0d274187aad6e5aed61de3e67d7bf423649 100644 (file)
@@ -713,13 +713,15 @@ function question_delete_activity($cm, $feedback=true) {
  * @param integer $newcategory the id of the category to move to.
  */
 function question_move_questions_to_category($questionids, $newcategory) {
+    global $DB;
+
     $result = true;
 
     // Move the questions themselves.
-    $result = $result && set_field_select('question', 'category', $newcategory, "id IN ($questionids)");
+    $result = $result && $DB->set_field_select('question', 'category', $newcategory, "id IN ($questionids)");
 
     // Move any subquestions belonging to them.
-    $result = $result && set_field_select('question', 'category', $newcategory, "parent IN ($questionids)");
+    $result = $result && $DB->set_field_select('question', 'category', $newcategory, "parent IN ($questionids)");
 
     // TODO Deal with datasets.