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

This commit is contained in:
Damyon Wiese 2017-12-12 09:56:20 +08:00
commit 8cae085071

View File

@ -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));
}
}