Creates a where filter statement for tokens that do not
have a correct name and are in a tokens table

@param string $from The tokens that should not occur
@param string $fieldName Name of database field to use
@return string
354635
protected function _getTokenFromSqlWhere($from, $fieldName)
    {
        $lsDb = $this->getSourceDatabase();
        $tokField = $lsDb->quoteIdentifier($fieldName);

        foreach (str_split($from) as $check) {
            $checks[] = 'LOCATE(' . $lsDb->quote($check) . ', ' . $tokField . ')';
        }

        return '(' . implode(' OR ', $checks) . ')';
    }
357780
private function splitVariantAndParamTokens(array $tokenBundle, $fromField)
    {
        if (PreferenceInterface::MIME === $fromField) {
            $this->validateBundleMimeVariant($tokenBundle);
            $variantTokenList = array_slice($tokenBundle, 0, 3);
            $paramTokenList = array_slice($tokenBundle, 3);
        } else {
            $variantTokenList = array_slice($tokenBundle, 0, 1);
            $paramTokenList = array_slice($tokenBundle, 1);
        }

        return array($variantTokenList, $paramTokenList);
    }
282801
private function getReplacementString($from, $to)
    {
        if (is_array($from) && is_array($to)) {
            if (count($from) == count($to)) {
                $sedStrings = [];
                $fromSize = count($from);
                for ($i = 0; $i < $fromSize; $i++) {
                    $sedStrings[] = $this->getReplacementCommand($from[$i], $to[$i]);
                }
                return implode(';', $sedStrings);
            } else {
                throw new InvalidArgumentException("Number of items in 'fromText' (" . count($from) . ") is different to 'toText' (" . count($to) . ")");
            }
        } elseif (is_array($from) || is_array($to)) {
            throw new InvalidArgumentException("Only one of fromText or toText is an array, both should be arrays or string");
        } else {
            return $this->getReplacementCommand($from, $to);
        }
    }
247909
public function removeFilterByFieldName($fieldName)
    {
        return $this->removeFilterByFunction(
            function($key, $query) use ($fieldName) {
                $queryString = $query->getQuery();
                $storedFieldName = substr($queryString,0, strpos($queryString, ":"));
                return $storedFieldName == $fieldName;
            }
        );
    }
139830
public function update(string $from, $wheres, array $values, array $options = [])
    {
        list($where, $bindings) = DBHelper::handleConditions($wheres, $this);

        $options['update'] = $this->qn($from);
        $options['where'] = $where;

        $statement = $this->compileUpdate($values, $bindings, $options);

        if (isset($options['returnSql'])) {
            return [$statement, $bindings];
        }

        return $this->fetchAffected($statement, $bindings);
    }
595834
public static function HasNonAsciiChars($fieldname)
	{
		require_once("verysimple/String/VerySimpleStringUtil.php");
		
		$val = isset($_REQUEST[$fieldname]) ? $_REQUEST[$fieldname] : '';
		return VerySimpleStringUtil::EncodeToHTML($val) != $val;
	}
215323
private function getAlteredQueryNode($fieldName, array $values)
    {
        $newNode = new OrNode();
        $defaultLanguageFieldName = $fieldName.'.'.$this->intUtils->getDefaultLanguage();

        foreach ($values as $singleValue) {
            $newNode->addQuery($this->getEqNode($fieldName, $singleValue));
            // search default language field (as new structure only has 'en' set after creation and no save)
            $newNode->addQuery(
                $this->getEqNode(
                    $defaultLanguageFieldName,
                    $singleValue
                )
            );
        }

        // add default match
        $newNode->addQuery($this->getEqNode($this->node->getField(), $this->getNodeValue()));

        if (!$this->nodeFieldNameHasLanguage()) {
            // if no language, we add it to the query to default node for default language
            $newNode->addQuery(
                $this->getEqNode(
                    $defaultLanguageFieldName,
                    $this->getNodeValue()
                )
            );
        }

        return $newNode;
    }
537811
public function prepareFieldName(string $fieldName) : string
    {
        $fieldNames = $this->prepareQueryElement($fieldName, null, null, false);

        return $fieldNames[0][0];
    }
640701
public function sqlDelete(
		$from,
		$where,
		array $where_params,
		$limit = null
	) {
		$sql = $this->queryBuilder->buildDelete($from, $where, $limit);
		$query = $this->database->prepare($sql);
		$query->execute($where_params);
		$this->addQuery($query->queryString, $where_params);
		return $query->rowCount();
	}
267192
protected function getFilterDescription(string $fieldName, string $operator): array
    {
        return [
            sprintf('%s[%s]', $fieldName, $operator) => [
                'property' => $fieldName,
                'type' => 'string',
                'required' => false,
            ],
        ];
    }
1185691
public static function fieldsKey($table, $filter="id") {

        try {
            $row = (array) self::findRow("select * from ".$table, "assoc");
            // remove array element base on filter if _none_ no filter
            if (strtolower($filter)!="_none_") {
                // default is to filter id field
                unset($row[$filter]);
            }
            return array_keys($row);
        } catch (Exception $e) {
            echo $e->getTraceAsString();
        }        
    }
605877
public function cuSelectOneDataSet($tableName, $fieldName, $fieldValue)
    {

        $where         = " $fieldName='$fieldValue' ";
        $dataSetsArray = $this->cuSelectAsArray($tableName, $where);

        $dataSetArray = null;
        if (array_key_exists(0, $dataSetsArray)) {
            $dataSetArray = $dataSetsArray[0];
        }

        return $dataSetArray;
    }
586289
public function delete($from)
    {
        $builder               = new Delete($this->driver);
        $this->lastQuery       = $builder;

        return $builder->from($from);
    }
770983
public function getFilter(string $fieldName): ?Condition
    {
        [$name, $filters] = $this->getArrayAndKeyName($fieldName, 'filters');

        return array_first($filters, function ($filter) use ($name) {
            return $filter->getName() === $name;
        });
    }
654455
public function removeFilterOn($fieldExpression)
    {
        $matched = false;

        // If given a parameterised condition extract only the condition
        if (is_array($fieldExpression)) {
            reset($fieldExpression);
            $fieldExpression = key($fieldExpression);
        }

        $where = $this->query->getWhere();
        // Iterate through each condition
        foreach ($where as $i => $condition) {
            // Rewrite condition groups as plain conditions before comparison
            if ($condition instanceof SQLConditionGroup) {
                $predicate = $condition->conditionSQL($parameters);
                $condition = array($predicate => $parameters);
            }

            // As each condition is a single length array, do a single
            // iteration to extract the predicate and parameters
            foreach ($condition as $predicate => $parameters) {
                // @see SQLSelect::addWhere for why this is required here
                if (strpos($predicate, $fieldExpression) !== false) {
                    unset($where[$i]);
                    $matched = true;
                }
                // Enforce single-item condition predicate => parameters structure
                break;
            }
        }

        // set the entire where clause back, but clear the original one first
        if ($matched) {
            $this->query->setWhere($where);
        } else {
            throw new InvalidArgumentException("Couldn't find $fieldExpression in the query filter.");
        }

        return $this;
    }
618488
private function matchClientPreferences($fromField, array $clientPrefList, array $matchingList)
    {
        foreach ($clientPrefList as $clientPref) {
            $matchingList = $this->matchSingleClientPreference($fromField, $clientPref, $matchingList);
        }

        return $matchingList;
    }
571200
public function getLocalizedFieldName($fieldName)
    {
        if ($this->isLocalizedField($fieldName) || $this->isLocalizedRelation($fieldName)) {
            return self::localized_field($fieldName);
        }
        trigger_error("Field '$fieldName' is not a localized field", E_USER_ERROR);
    }