PHP Класс SqlParser\Utils\Query

Автор: Dan Ungureanu ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$FUNCTIONS array Functions that set the flag is_func.

Открытые методы

Метод Описание
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.

Описание методов

getAll() публичный статический Метод

Parses a query and gets all information about it.
public static getAll ( string $query ) : array
$query string The query to be parsed.
Результат 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() публичный статический Метод

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.
Результат string

getClauseStartOffset() публичный статический Метод

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.
Результат integer

getFirstStatement() публичный статический Метод

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.
Результат array Array containing the first full query, the remaining part of the query and the last delimiter.

getFlags() публичный статический Метод

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.
Результат array

getTables() публичный статический Метод

Gets a list of all tables used in this statement.
public static getTables ( Statement $statement ) : array
$statement SqlParser\Statement Statement to be scanned.
Результат array

replaceClause() публичный статический Метод

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.
Результат string

replaceClauses() публичный статический Метод

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.
Результат string

Описание свойств

$FUNCTIONS публичное статическое свойство

Functions that set the flag is_func.
public static array $FUNCTIONS
Результат array