]> git.mjollnir.org Git - moodle.git/commitdiff
Now both check_constraint_exists() and find_check_constraint_name()
authorstronk7 <stronk7>
Mon, 10 Sep 2007 22:42:04 +0000 (22:42 +0000)
committerstronk7 <stronk7>
Mon, 10 Sep 2007 22:42:04 +0000 (22:42 +0000)
are working under mysql, postgresql and mssql. 1st step of MDL-9356

lib/ddllib.php

index 6867596f2ad1ac3724ca4e2b3ad1b7865fda0451..ed6117f7db49579aaf755a85d59412c10a9b413c 100644 (file)
@@ -517,7 +517,7 @@ function find_check_constraint_name($table, $field) {
 
 /// Do this function silenty (to avoid output in install/upgrade process)
     $olddbdebug = $db->debug;
-    //$db->debug = false;
+    $db->debug = false;
 
 /// Check the table exists
     if (!table_exists($table)) {
@@ -538,13 +538,17 @@ function find_check_constraint_name($table, $field) {
 /// Calculate the name of the table
     $tablename = $generator->getTableName($table, false);
 
-/// Get list of check_constraints in table
+/// Get list of check_constraints in table/field
     $checks = null;
-    if ($checks = $generator->getCheckConstraintsFromDB($table, $field)) {
-        $checks = array_change_key_case($checks, CASE_LOWER);
+    if ($objchecks = $generator->getCheckConstraintsFromDB($table, $field)) {
+    /// Get only the 1st element. Shouldn't be more than 1 under XMLDB
+        $objcheck = array_shift($objchecks);
+        if ($objcheck) {
+            $checks = strtolower($objcheck->name);
+        }
     }
 
-/// Arriving here, index not found
+/// Arriving here, check not found
     $db->debug = $olddbdebug; //Re-set original $db->debug
     return $checks;
 }