PHP Class SqlParser\Utils\Query

Author: Dan Ungureanu ([email protected])
Afficher le fichier Open project: phpmyadmin/sql-parser Class Usage Examples

Méthodes publiques

Свойство Type Description
$FUNCTIONS array Functions that set the flag is_func.

Méthodes publiques

Méthode Description
getAll ( string $query ) : array Parses a query and gets all information about it.
getClause ( Statement $statement, TokensList $list, string $clause, integer | string $type, boolean $skipFirst = true ) : string Gets a specific clause.
getClauseStartOffset ( Statement $statement, TokensList $list, string $clause ) : integer Gets a starting offset of a specific clause.
getFirstStatement ( string $query, string $delimiter = null ) : array Gets the first full statement in the query.
getFlags ( Statement | null $statement, boolean $all = false ) : array Gets an array with flags this statement has.
getTables ( Statement $statement ) : array Gets a list of all tables used in this statement.
replaceClause ( Statement $statement, TokensList $list, string $old, string $new = null, boolean $onlyType = false ) : string Builds a query by rebuilding the statement from the tokens list supplied and replaces a clause.
replaceClauses ( Statement $statement, TokensList $list, array $ops ) : string Builds a query by rebuilding the statement from the tokens list supplied and replaces multiple clauses.

Method Details

getAll() public static méthode

Parses a query and gets all information about it.
public static getAll ( string $query ) : array
$query string The query to be parsed.
Résultat array The array returned is the one returned by `static::getFlags()`, with the following keys added: - parser - the parser used to analyze the query; - statement - the first statement resulted from parsing; - select_tables - the real name of the tables selected; if there are no table names in the `SELECT` expressions, the table names are fetched from the `FROM` expressions - select_expr - selected expressions

getClause() public static méthode

Gets a specific clause.
public static getClause ( Statement $statement, TokensList $list, string $clause, integer | string $type, boolean $skipFirst = true ) : string
$statement SqlParser\Statement The parsed query that has to be modified.
$list SqlParser\TokensList The list of tokens.
$clause string The clause to be returned.
$type integer | string The type of the search. If int, -1 for everything that was before 0 only for the clause 1 for everything after If string, the name of the first clause that should not be included.
$skipFirst boolean Whether to skip the first keyword in clause.
Résultat string

getClauseStartOffset() public static méthode

Gets a starting offset of a specific clause.
public static getClauseStartOffset ( Statement $statement, TokensList $list, string $clause ) : integer
$statement SqlParser\Statement The parsed query that has to be modified.
$list SqlParser\TokensList The list of tokens.
$clause string The clause to be returned.
Résultat integer

getFirstStatement() public static méthode

Gets the first full statement in the query.
public static getFirstStatement ( string $query, string $delimiter = null ) : array
$query string The query to be analyzed.
$delimiter string The delimiter to be used.
Résultat array Array containing the first full query, the remaining part of the query and the last delimiter.

getFlags() public static méthode

Gets an array with flags this statement has.
public static getFlags ( Statement | null $statement, boolean $all = false ) : array
$statement SqlParser\Statement | null The statement to be processed.
$all boolean If `false`, false values will not be included.
Résultat array

getTables() public static méthode

Gets a list of all tables used in this statement.
public static getTables ( Statement $statement ) : array
$statement SqlParser\Statement Statement to be scanned.
Résultat array

replaceClause() public static méthode

It is a very basic version of a query builder.
public static replaceClause ( Statement $statement, TokensList $list, string $old, string $new = null, boolean $onlyType = false ) : string
$statement SqlParser\Statement The parsed query that has to be modified.
$list SqlParser\TokensList The list of tokens.
$old string The type of the clause that should be replaced. This can be an entire clause.
$new string The new clause. If this parameter is omitted it is considered to be equal with `$old`.
$onlyType boolean Whether only the type of the clause should be replaced or the entire clause.
Résultat string

replaceClauses() public static méthode

Builds a query by rebuilding the statement from the tokens list supplied and replaces multiple clauses.
public static replaceClauses ( Statement $statement, TokensList $list, array $ops ) : string
$statement SqlParser\Statement The parsed query that has to be modified.
$list SqlParser\TokensList The list of tokens.
$ops array Clauses to be replaced. Contains multiple arrays having two values: array($old, $new). Clauses must be sorted.
Résultat string

Property Details

$FUNCTIONS public_oe static_oe property

Functions that set the flag is_func.
public static array $FUNCTIONS
Résultat array