Commit 8cae0850 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

Merge branch 'MDL-60976-master' of https://github.com/matt-catalyst/moodle

parents 47864439 1c06098b
......@@ -2402,21 +2402,25 @@ abstract class moodle_database {
// Enclose the column name by the proper quotes if it's a reserved word.
$columnname = $this->get_manager()->generator->getEncQuoted($column->name);
$searchsql = $this->sql_like($columnname, '?');
$searchparam = '%'.$this->sql_like_escape($search).'%';
$sql = "UPDATE {".$table."}
SET $columnname = REPLACE($columnname, ?, ?)
WHERE $columnname IS NOT NULL";
WHERE $searchsql";
if ($column->meta_type === 'X') {
$this->execute($sql, array($search, $replace));
$this->execute($sql, array($search, $replace, $searchparam));
} else if ($column->meta_type === 'C') {
if (core_text::strlen($search) < core_text::strlen($replace)) {
$colsize = $column->max_length;
$sql = "UPDATE {".$table."}
SET $columnname = " . $this->sql_substr("REPLACE(" . $columnname . ", ?, ?)", 1, $colsize) . "
WHERE $columnname IS NOT NULL";
WHERE $searchsql";
}
$this->execute($sql, array($search, $replace));
$this->execute($sql, array($search, $replace, $searchparam));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment