mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
Fixed bug when inserting strings beginning by single quotes. MDL-10788
This commit is contained in:
parent
dda4bbbf25
commit
295ce0c81e
1 changed files with 10 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
<?php /// $Id $
|
||||
<?php
|
||||
|
||||
/// $Id $
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
|
@ -7,7 +9,7 @@
|
|||
// ADOdb - Database Abstraction Library for PHP //
|
||||
// http://adodb.sourceforge.net/ //
|
||||
// //
|
||||
// Copyright (C) 2000-2006 John Lim (jlim\@natsoft.com.my) //
|
||||
// Copyright (C) 2000-2007 John Lim (jlim\@natsoft.com.my) //
|
||||
// All rights reserved. //
|
||||
// Released under both BSD license and LGPL library license. //
|
||||
// Whenever there is any discrepancy between the two licenses, //
|
||||
|
@ -69,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) {
|
||||
|
||||
|
@ -125,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) {
|
||||
|
@ -140,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue