Fixed bug when inserting strings beginning by single quotes. MDL-10788
Merged from MOODLE_18_STABLE
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
/// $Id $
|
||||
|
||||
@@ -71,7 +71,7 @@ class ADODB_mssql_n extends ADODB_mssql {
|
||||
* the "N" notation when working against MSSQL.
|
||||
*
|
||||
* Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,
|
||||
* nvarchar and ntext
|
||||
* nvarchar and ntext
|
||||
*/
|
||||
function _appendN($sql) {
|
||||
|
||||
@@ -127,6 +127,7 @@ class ADODB_mssql_n extends ADODB_mssql {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Analyse literals to prepend the N char to them if their contents aren't numeric
|
||||
if (!empty($literals)) {
|
||||
foreach ($literals as $key=>$value) {
|
||||
@@ -142,6 +143,10 @@ class ADODB_mssql_n extends ADODB_mssql {
|
||||
$result = str_replace(array_keys($literals), $literals, $result);
|
||||
}
|
||||
|
||||
/// Any pairs followed by N' must be switched to N' followed by those pairs
|
||||
/// (or strings beginning with single quotes will fail)
|
||||
$result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);
|
||||
|
||||
/// Re-apply pairs of single-quotes to the text
|
||||
if (!empty($pairs)) {
|
||||
$result = str_replace(array_keys($pairs), $pairs, $result);
|
||||
@@ -163,4 +168,4 @@ class ADORecordset_mssql_n extends ADORecordset_mssql {
|
||||
$this->ADORecordset_mssql($id,$mode);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user