PHP Class SqlParser\Context

Show file Open project: phpmyadmin/sql-parser Class Usage Examples

Public Properties

Property Type Description
$KEYWORDS array Because, PHP's associative arrays are basically hash tables, it is more efficient to store keywords as keys instead of values. The value associated to each keyword represents its flags.
$MODE integer The mode of the MySQL server that will be used in lexing, parsing and building the statements.
$OPERATORS array List of operators and their flags.
$contextPrefix string The prefix concatenated to the context name when an incomplete class name is specified.
$defaultContext string The name of the default content.
$loadedContext string The name of the loaded context.

Public Methods

Method Description
escape ( array | string $str, string $quote = '`' ) : string Escapes the symbol by adding surrounding backticks.
isBool ( string $str ) : boolean Checks if the given string is a boolean value.
isComment ( string $str ) : integer Checks if the given string is the beginning of a whitespace.
isKeyword ( string $str, boolean $isReserved = false ) : integer Checks if the given string is a keyword.
isNumber ( string $str ) : boolean Checks if the given character can be a part of a number.
isOperator ( string $str ) : integer Checks if the given string is an operator.
isSeparator ( string $str ) : boolean Checks if the given character can be a separator for two lexeme.
isString ( string $str ) : integer Checks if the given character is the beginning of a string.
isSymbol ( string $str ) : integer Checks if the given character is the beginning of a symbol. A symbol can be either a variable or a field name.
isWhitespace ( string $str ) : boolean Checks if the given character is a whitespace.
load ( string $context = '' ) : void Loads the specified context.
loadClosest ( string $context = '' ) : string Loads the context with the closest version to the one specified.
setMode ( string $mode = '' ) : void Sets the SQL mode.

Method Details

escape() public static method

Escapes the symbol by adding surrounding backticks.
public static escape ( array | string $str, string $quote = '`' ) : string
$str array | string The string to be escaped.
$quote string Quote to be used when escaping.
return string

isBool() public static method

This actually check only for TRUE and FALSE because 1 or 0 are actually numbers and are parsed by specific methods.
public static isBool ( string $str ) : boolean
$str string String to be checked.
return boolean

isComment() public static method

Checks if the given string is the beginning of a whitespace.
public static isComment ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the comment type.

isKeyword() public static method

Checks if the given string is a keyword.
public static isKeyword ( string $str, boolean $isReserved = false ) : integer
$str string String to be checked.
$isReserved boolean Checks if the keyword is reserved.
return integer

isNumber() public static method

Checks if the given character can be a part of a number.
public static isNumber ( string $str ) : boolean
$str string String to be checked.
return boolean

isOperator() public static method

Checks if the given string is an operator.
public static isOperator ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the operator.

isSeparator() public static method

Checks if the given character can be a separator for two lexeme.
public static isSeparator ( string $str ) : boolean
$str string String to be checked.
return boolean

isString() public static method

Checks if the given character is the beginning of a string.
public static isString ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the string type.

isSymbol() public static method

Checks if the given character is the beginning of a symbol. A symbol can be either a variable or a field name.
public static isSymbol ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the symbol type.

isWhitespace() public static method

Checks if the given character is a whitespace.
public static isWhitespace ( string $str ) : boolean
$str string String to be checked.
return boolean

load() public static method

Contexts may be used by accessing the context directly.
public static load ( string $context = '' ) : void
$context string Name of the context or full class name that defines the context.
return void

loadClosest() public static method

The closest context is found by replacing last digits with zero until one is loaded successfully.
See also: Context::load()
public static loadClosest ( string $context = '' ) : string
$context string Name of the context or full class name that defines the context.
return string The loaded context. `null` if no context was loaded.

setMode() public static method

Sets the SQL mode.
public static setMode ( string $mode = '' ) : void
$mode string The list of modes. If empty, the mode is reset.
return void

Property Details

$KEYWORDS public static property

Because, PHP's associative arrays are basically hash tables, it is more efficient to store keywords as keys instead of values. The value associated to each keyword represents its flags.
public static array $KEYWORDS
return array

$MODE public static property

The mode of the MySQL server that will be used in lexing, parsing and building the statements.
public static int $MODE
return integer

$OPERATORS public static property

List of operators and their flags.
public static array $OPERATORS
return array

$contextPrefix public static property

The prefix concatenated to the context name when an incomplete class name is specified.
public static string $contextPrefix
return string

$defaultContext public static property

The name of the default content.
public static string $defaultContext
return string

$loadedContext public static property

The name of the loaded context.
public static string $loadedContext
return string