Postgres::changeFtsMapping PHP Method

changeFtsMapping() public method

Creates/updates/deletes FTS mapping.
public changeFtsMapping ( $ftscfg, array $mapping, string $action, string $dictname = null )
$mapping array Array of tokens' names
$action string What to do with the mapping: add, alter or drop
$dictname string Dictionary that will process tokens given or null in case of drop action
    function changeFtsMapping($ftscfg, $mapping, $action, $dictname = null)
    {
        if (count($mapping) > 0) {
            $f_schema = $this->_schema;
            $this->fieldClean($f_schema);
            $this->fieldClean($ftscfg);
            $this->fieldClean($dictname);
            $this->arrayClean($mapping);
            switch ($action) {
                case 'alter':
                    $whatToDo = "ALTER";
                    break;
                case 'drop':
                    $whatToDo = "DROP";
                    break;
                default:
                    $whatToDo = "ADD";
                    break;
            }
            $sql = "ALTER TEXT SEARCH CONFIGURATION \"{$f_schema}\".\"{$ftscfg}\" {$whatToDo} MAPPING FOR ";
            $sql .= implode(",", $mapping);
            if ($action != 'drop' && !empty($dictname)) {
                $sql .= " WITH {$dictname}";
            }
            return $this->execute($sql);
        } else {
            return -1;
        }
    }
Postgres