]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed bug when inserting strings beginning by single quotes. MDL-10788
authorstronk7 <stronk7>
Fri, 10 Aug 2007 00:50:04 +0000 (00:50 +0000)
committerstronk7 <stronk7>
Fri, 10 Aug 2007 00:50:04 +0000 (00:50 +0000)
Merged from MOODLE_18_STABLE

lib/adodb/drivers/adodb-mssql_n.inc.php

index d112f89ab653dc6900ed40d0f766cff7982c60e0..e740aacffab2b3b1fd56bcca3a8275d7c9b30d71 100644 (file)
@@ -1,4 +1,4 @@
-<?php  \r
+<?php\r
 \r
 /// $Id $\r
 \r
@@ -71,7 +71,7 @@ class ADODB_mssql_n extends ADODB_mssql {
      * the "N" notation when working against MSSQL.\r
      *\r
      * Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,\r
-     * nvarchar and ntext \r
+     * nvarchar and ntext\r
      */\r
     function _appendN($sql) {\r
 \r
@@ -127,6 +127,7 @@ class ADODB_mssql_n extends ADODB_mssql {
             }\r
         }\r
 \r
+\r
     /// Analyse literals to prepend the N char to them if their contents aren't numeric\r
         if (!empty($literals)) {\r
             foreach ($literals as $key=>$value) {\r
@@ -142,6 +143,10 @@ class ADODB_mssql_n extends ADODB_mssql {
             $result = str_replace(array_keys($literals), $literals, $result);\r
         }\r
 \r
+    /// Any pairs followed by N' must be switched to N' followed by those pairs\r
+    /// (or strings beginning with single quotes will fail)\r
+        $result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);\r
+\r
     /// Re-apply pairs of single-quotes to the text\r
         if (!empty($pairs)) {\r
             $result = str_replace(array_keys($pairs), $pairs, $result);\r
@@ -163,4 +168,4 @@ class ADORecordset_mssql_n extends ADORecordset_mssql {
                $this->ADORecordset_mssql($id,$mode);\r
        }\r
 }\r
-?>
\ No newline at end of file
+?>\r