Escapes and quotes provided scalar value.

@param string $value Value to be escaped and quoted.
@return string The escaped and quoted value.
@throws \RuntimeException
197572
public function escapeAndQuote($value)
    {
        if (null === $value) {
            $pdoType = \PDO::PARAM_NULL;
        } else {
            $pdoType = \PDO::PARAM_STR;
        }

        return $this->getPdo()->quote($value, $pdoType);
    }
1287499
private function getEscape($value = '$value')
    {
        if ($this->customEscape) {
            return sprintf(self::CUSTOM_ESCAPE, $value);
        }

        return sprintf(self::DEFAULT_ESCAPE, $value, var_export($this->entityFlags, true), var_export($this->charset, true));
    }
157924
public static function escapeString($value)
    {
        if (version_compare(VERSION, '4.0', '<'))
        {
            $db = \Contao\Database::getInstance();

            if ($db instanceof \Contao\Database\Mysqli)
            {
                $db    = Contao3MysqliHelper::getInstance();
                $value = "'" . $db->getConnection()->real_escape_string($value) . "'";
            }
            else
            {
                if ($db instanceof \Contao\Database\Mysql)
                {
                    $db    = Contao3MysqlHelper::getInstance();
                    $value = "'" . mysql_real_escape_string($value, $db->getConnection()) . "'";
                }
            }
        }
        else
        {
            $connection = System::getContainer()->get('database_connection');
            $value      = $connection->quote($value);
        }

        return $value;
    }
630664
public function escape($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) : $value;
    }
917239
public function escape( $value ) {
		$value = (string)$value;

		if( $this->enableBool ) {
			if( $value == '' ) {
				return 'false';
			} elseif( $value == '1' ) {
				return 'true';
			}
		}

		if( $this->enableNumeric && is_numeric($value) ) {
			return (string)$value;
		}

		if( $this->enableAlphaNumeric && is_string($value) && ctype_alnum($value) && !is_numeric($value) ) {
			return (string)$value;
		}

		return var_export($value, true);
	}
1029065
public function quote($value)
    {
        $PdoConnection = $this->getPdoConnection();
        
        // If a PDO database connection is set, use it to quote the value using
        // the underlying database. Otherwise, quote it manually.
        if ($PdoConnection) {
            return $PdoConnection->quote($value);
        } elseif (is_null($value)) {
            return "NULL";
        } else {
            return "'" . addslashes($value) . "'";
        }
    }
393013
public function escape($value)
	{

		//put this in try...catch block for better error handling
		try{

			//check if there is a valid service instance
			if (! $this->validService() ) 
			{
				//throw exceptions
				throw new MySQLException("Not connected to a valid database service");

			}

			//escape and return output
			return $this->service->real_escape_string($value);

		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}
		
	}
10464
protected function _quote($value)
    {
        if (is_int($value) || is_float($value)) {
            return $value;
        }
        $this->_connect();
        return "'" . $this->_connection->real_escape_string($value) . "'";
    }
945817
public static function escape( $value )
	{
		if ( $value instanceof Htmlable )
			return $value->toHtml();

		return htmlentities( $value, ENT_QUOTES, 'UTF-8', false );
	}
759179
private function prepareValue($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if (strpos($value, "\n") !== false) {
            $values = explode("\n", $value);
            foreach ($values as &$line) {
                $line = $this->getIndentation(8) . $line;
            }
            $value = implode("\n", $values);

            return "|\n" . $value;
        }

        return '\'' . str_replace('\'', '\'\'', $value) . '\'';
    }
755376
private function getStatusString(Value $value): string
    {
        switch ($value->getStatus()) {
            case Value::STATUS_DRAFT:
                return 'DRAFT';
            case Value::STATUS_PUBLISHED:
                return 'PUBLISHED';
            case Value::STATUS_ARCHIVED:
                return 'ARCHIVED';
        }

        throw new RuntimeException(sprintf("Unknown status '%s'", var_export($value->getStatus(), true)));
    }
189492
private function escape($value)
    {
        if (1 !== preg_match($this->escapeCharacterPattern, $value)) {
            return htmlspecialchars($value, ENT_QUOTES);
        }

        return str_replace(
            $this->controlCharacters, $this->escapeCharacters, htmlspecialchars($value, ENT_QUOTES)
        );
    }
62444
public function matches(string $value): bool
    {
        $check = @preg_match($this->pattern, $value);
        if (false === $check) {
            throw new \RuntimeException(sprintf(
                    'Failure while matching "%s", reason: %s.',
                    $this->pattern,
                    $this->messageFor(preg_last_error())
            ));
        }

        return ((1 != $check) ? (false) : (true));
    }
443982
private function escapeParamValue($value)
    {
        $count = 0;
        $value = str_replace('\\', '\\\\', $value);
        $value = str_replace('"', '\"', $value, $count);
        $value = str_replace("\n", '\\n', $value);
        if (false !== strpos($value, ';') || false !== strpos($value, ',') || false !== strpos($value, ':') || $count) {
            $value = '"' . $value . '"';
        }

        return $value;
    }
1329805
public function quoteValue($value)
    {
        if ($value === null) {
            return 'NULL';
        }

        if (is_numeric($value)) {
            return $value;
        }

        if ($value === false) {
            return 0;
        }

        if (empty($value)) {
            return '\'\'';
        }

        if (is_array($value)) {
            $values = array_unique($value);
            foreach ($values as $key => $value) {
                $values[$key] = $value === null ? 'NULL' : $this->_adapter->quoteValue($value);
            }

            return $values = implode(', ', $values);
        }

        return $this->_adapter->quoteValue($value);
    }
1236365
public function escape($value)
	{
		// Make sure the database is connected
		$this->_connection or $this->connect();

		$result = $this->_connection->quote($value);
		// poor-mans workaround for the fact that not all drivers implement quote()
		if (empty($result))
		{
			$result = "'".str_replace("'", "''", $value)."'";
		}
		return $result;
	}
41562
private function quoteValue($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if ($value === null) {
            return 'null';
        }

        return $this->getConnection()->quote($value);
    }