]> git.mjollnir.org Git - moodle.git/commitdiff
Substring MSSQL function *requires* 3rd parameter - MDL-16655 ; merged from 19_STABLE
authorstronk7 <stronk7>
Wed, 24 Sep 2008 17:35:42 +0000 (17:35 +0000)
committerstronk7 <stronk7>
Wed, 24 Sep 2008 17:35:42 +0000 (17:35 +0000)
lib/accesslib.php

index 8913bceeca69905645f0a67bfa27ae429e8b7739..84a731d62d67b79f8c7fa7a66b4b632b1d0a3f45 100755 (executable)
@@ -5403,8 +5403,13 @@ function context_moved($context, $newparent) {
     $DB->execute($sql, $params);
 
     $len = strlen($frompath);
+    /// MDL-16655 - Substring MSSQL function *requires* 3rd parameter
+    $substr3rdparam = '';
+    if ($DB->get_dbfamily() == 'mssql') {
+        $substr3rdparam = ', len(path)';
+    }
     $sql = "UPDATE {context}
-               SET path = ".$DB->sql_concat("?", 'SUBSTR(path, '.$len.' +1)')."
+               SET path = ".$DB->sql_concat("?", $DB->sql_substr() .'(path, '.$len.' +1'.$substr3rdparam.')')."
                    $setdepth
              WHERE path LIKE ?";
     $params = array($newpath, "{$frompath}/%");