PMA\libraries\controllers\table\TableSearchController::getReplacePreview PHP Method

getReplacePreview() public method

Returns HTML for previewing strings found and their replacements
public getReplacePreview ( integer $columnIndex, string $find, string $replaceWith, boolean $useRegex, string $charSet ) : string
$columnIndex integer index of the column
$find string string to find in the column
$replaceWith string string to replace with
$useRegex boolean to use Regex replace or not
$charSet string character set of the connection
return string HTML for previewing strings found and their replacements
    function getReplacePreview($columnIndex, $find, $replaceWith, $useRegex, $charSet)
    {
        $column = $this->_columnNames[$columnIndex];
        if ($useRegex) {
            $result = $this->_getRegexReplaceRows($columnIndex, $find, $replaceWith, $charSet);
        } else {
            $sql_query = "SELECT " . Util::backquote($column) . "," . " REPLACE(" . Util::backquote($column) . ", '" . $find . "', '" . $replaceWith . "')," . " COUNT(*)" . " FROM " . Util::backquote($this->db) . "." . Util::backquote($this->table) . " 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
            $sql_query .= " GROUP BY " . Util::backquote($column) . " ORDER BY " . Util::backquote($column) . " ASC";
            $result = $this->dbi->fetchResult($sql_query, 0);
        }
        return Template::get('table/search/replace_preview')->render(array('db' => $this->db, 'table' => $this->table, 'columnIndex' => $columnIndex, 'find' => $find, 'replaceWith' => $replaceWith, 'useRegex' => $useRegex, 'result' => $result));
    }