public function replace($columnIndex, $find, $replaceWith, $useRegex, $charSet)
{
$column = $this->_columnNames[$columnIndex];
if ($useRegex) {
$toReplace = $this->_getRegexReplaceRows($columnIndex, $find, $replaceWith, $charSet);
$sql_query = "UPDATE " . Util::backquote($this->table) . " SET " . Util::backquote($column) . " = CASE";
if (is_array($toReplace)) {
foreach ($toReplace as $row) {
$sql_query .= "\n WHEN " . Util::backquote($column) . " = '" . $GLOBALS['dbi']->escapeString($row[0]) . "' THEN '" . $GLOBALS['dbi']->escapeString($row[1]) . "'";
}
}
$sql_query .= " END" . " WHERE " . Util::backquote($column) . " RLIKE '" . $GLOBALS['dbi']->escapeString($find) . "' COLLATE " . $charSet . "_bin";
// here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
// is case sensitive
} else {
$sql_query = "UPDATE " . Util::backquote($this->table) . " SET " . Util::backquote($column) . " =" . " REPLACE(" . Util::backquote($column) . ", '" . $find . "', '" . $replaceWith . "')" . " WHERE " . Util::backquote($column) . " LIKE '%" . $find . "%' COLLATE " . $charSet . "_bin";
// here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
// is case sensitive
}
$this->dbi->query($sql_query, null, DatabaseInterface::QUERY_STORE);
$GLOBALS['sql_query'] = $sql_query;
}