PHP 클래스 SqlParser\Utils\Query

저자: Dan Ungureanu ([email protected])
파일 보기 프로젝트 열기: phpmyadmin/sql-parser 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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