Returns a literal for a string value that can be safely used in SQL statements.

@param string|null $value The value.

@return string
165405
public function quoteString(?string $value): string
  {
    if ($value===null || $value==='') return 'null';

    return "'".$this->mysqli->real_escape_string($value)."'";
  }
776966
public function wrap($value)
		{
			// Expressions should be injected into the query as raw strings so
			// so we do not want to wrap them in any way. We will just return
			// the string value from the expression to be included.
			if ($value instanceof Expression) return $value->get();

			// If the value being wrapped contains a column alias, we need to
			// wrap it a little differently as each segment must be wrapped
			// and not the entire string.
			if (strpos(strtolower($value), ' as ') !== false) {
				$segments = explode(' ', $value);

				return sprintf(
					'%s AS %s',
					$this->wrap($segments[0]),
					$this->wrap($segments[2])
				);
			}

			// Since columns may be prefixed with their corresponding table
			// name so as to not make them ambiguous, we will need to wrap
			// the table and the column in keyword identifiers.
			foreach (explode('.', $value) as $segment) {
				if ($segment == '*') {
					$wrapped[] = $segment;
				} else {
					$wrapped[] = sprintf($this->wrapper, $segment);
				}
			}

			return implode('.', $wrapped);
		}
688003
public static function parseString($value) {
        if (null === $value) {
            return null;
        }
        if (0 === preg_match("/^[0-9]{1,}(\.[0-9]{0,})?$/", $value)) {
            throw new FloatArgumentException($value);
        }
        return floatval($value);
    }
373490
public function esc(?string $value): string
    {
        if ($value === null) {
            return 'NULL';
        }

        $value = substr($this->pdo->quote($value), 1, -1);

        return $value;
    }
1035685
private function getNativeValueFromDefinition($value)
    {
        if ($this->strStartsWith($value, "'") && $this->strEndsWith($value, "'")) {
            $value = trim(trim($value, "'")); // single quote
        } else {
            if ($this->strStartsWith($value, '"') && $this->strEndsWith($value, '"')) {
                $value = trim(trim($value, '"')); // double quote
            } else {
                if ($value == 'true') {
                    $value = true;
                } else {
                    if ($value == 'false') {
                        $value = false;
                    } else {
                        if (is_numeric($value)) {
                            if (ctype_digit($value)) {
                                return (integer)$value;
                            } else {
                                return (float)$value;
                            }
                        }
                    }
                }
            }
        }

        return $value;
    }
304424
public static function ToString( $value )
	{
		if ( is_string( $value ) )

			return $value;

		if ( is_null( $value ) )

			return "false";

		if ( is_bool( $value ) )

			return $value ? "true" : "false";

		if ( $value instanceof TrueValue )

			return "true";

		if ( $value instanceof FalseValue )

			return "false";

		if ( $value instanceof Integer )

			return $value->ToString( null );

		if ( $value instanceof DecimalValue )

			return $value->getRound( 18 )->ToString( null );

		if ( is_numeric( $value ) && ( is_int( $value ) || $value == PHP_INT_MIN ) ) // PHP does not seem to detect PHP_INT_MIN as an int

			return $value . "";

		if ( is_numeric( $value ) && is_nan( $value ) )
		{
			return "NaN";
		}

		if ( is_numeric( $value ) && is_double( $value ) )
		{
			// Using sprintf( "%e", $value ) is not good enough because it will
			// only produce number with a maximum of 7 significant digits
			/* if( preg_match( "/^(?<sign>-)?(?<zeros>0\.0*)/", $value, $m ) )
			{
				$zeroes = strlen( $m['zeros'] );
				$sign = strlen( $m['sign'] );
				return ( $sign ? "-" : "" ) . substr( $value, $zeroes + $sign, 1 ) . rtrim( "." . substr( $value, $zeroes + $sign + 1 ), "0." ) . "E-" . ( $zeroes-1 );
			}
			else
			 */
			if( preg_match( "/^(?<sign>-)?(?<digits>\d{7,})(?:\.(?<decimals>\d+))?/", $value, $m ) )
			{
				$zeroes = strlen( $m['digits'] );
				$sign = strlen( $m['sign'] );
				$d = rtrim( "." . substr( $m['digits'], 1 ) . ( isset( $m['decimals'] ) ? $m['decimals'] : "" ), "0." );
				if ( empty( $d ) ) $d = ".0";
				$x = ( $sign ? "-" : "" ) . substr( $value, 0 + $sign, 1 ) . $d . "E" . ( $zeroes - 1 );
				return $x;
			}

			return str_replace( "+", "", $value . "" );
		}

		if ( $value instanceof \DateInterval )
		{
			return ( new DurationValue( $value ) )->ToString();
			// return ( new YearMonthDurationValue( $value ) )->ToString();
			// return ( new DayTimeDurationValue( $value ) )->ToString();
		}

		if ( $value instanceof \DateTime )
		{
			$format = "";
			if ( property_exists( $value, "isDate" ) && $value->isDate ) $format .= "Y-m-d";
			if ( property_exists( $value, "isTime" ) && $value->isTime ) $format .= ( empty( $format ) ? "" :"\T" ) . "H:i:s";
			$format .= ( $value->getTimezone()->getName() == date_default_timezone_get() ? "" : "P" );
			return  $value->format( $format ); // DateTimeValue::fromDate( false, $value ) )->ToString();
		}

		return $value->ToString();
	}
232747
public static function getStringValue($value): string
    {
        if ($value instanceof \DateTime) {
            return $value->format(self::DEFAULT_DATETIME_FORMAT);
        } elseif (is_bool($value)) {
            return $value ? 'true' : 'false';
        } elseif (is_array($value)) {
            return implode(', ', array_map('self::getStringValue', $value));
        }

        return (string) $value;
    }
1018847
private function parseValue($value)
    {
        if (substr($value, 0, 1) === '"' && substr($value, -1, 1) === '"') {
            return substr($value, 1, -1);
        }

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

        throw new LogicException(sprintf('Can\'t parse the value: "%s"', $value));
    }
1143349
public static function stringify($value)
    {
        if (is_string($value)) {
            return $value;
        }
        if ($value === null || is_bool($value)) {
            return var_export($value, true);
        }

        if (is_array($value) || (is_object($value) && !method_exists($value, '__toString'))) {
            return json_encode($value, JSON_ERROR_NONE | JSON_UNESCAPED_SLASHES);
        }
        return (string)$value;
    }
95877
protected function escape($value)
    {
        if ($value === null) {
            return 'NULL';
        }

        if (is_integer($value) || is_float($value)) {
            return $value;
        }

        return $this->pdo->quote($value);
    }
331723
protected function formatValue($value)
    {
        if ($this->formatValue !== NULL) {
            return str_replace(static::VALUE_IDENTIFIER, $value, $this->formatValue);
        } else {
            return $value;
        }
    }
191788
protected function secureValue( $value ){
#		if( !ini_get( 'magic_quotes_gpc' ) )
#			$value = addslashes( $value );
#		$value	= htmlentities( $value );
		if ( $value === NULL )
			return "NULL";
		$value	= $this->dbc->quote( $value );
		return $value;
	}
1328429
public function prepareValue($value)
    {
        return $value === null ? null : Carbon::createFromFormat($this->format, $value)->toDateString();
    }
610910
public function namePrefix($value = null)
    {
        if ($value !== null) {
            $this->_namePrefix = $value;
        }

        return $this->_namePrefix;
    }
1338045
private static function getStringValue($value) : string {
        if(is_bool($value)) {
            return $value === true ? 'true' : 'false';
        }
        return !is_string($value) ? strval($value) : $value;
    }
215527
private static function tostring($value) : string
    {
        if (!isset($value)) {
            return 'NULL';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }
        if (is_numeric($value)) {
            return $value;
        }
        if (is_string($value)) {
            return "'$value'";
        }
        if (is_array($value)) {
            $out = '[';
            $i = 0;
            foreach ($value as $key => $entry) {
                if ($i) {
                    $out .= ', ';
                }
                $out .= $key.' => '.self::tostring($entry);
                $i++;
            }
            $out .= ']';
            return $out;
        }
        if (is_object($value)) {
            if (method_exists($value, '__toString')) {
                return "$value";
            } else {
                return get_class($value);
            }
        }
    }
133458
protected function processScalarValue($value)/*# : string */
    {
        if (ClauseInterface::NO_VALUE == $value) {
            return '?';
        } elseif (is_null($value) || is_bool($value)) {
            return strtoupper(var_export($value, true));
        } else {
            return $this->getBuilder()->getParameter()->getPlaceholder($value);
        }
    }