\QueryTableParser

class QueryTableParser

Very rough class to extract table names from a SQL query.

This class simply looks for specific tokens like FROM, JOIN, UPDATE, INTO and collects a list of the very next token after those words.

It doesn't attempt to parse aliases, or any other query structure.

This probably doesn't handle table names with a space in it like table name

Summary

Methods
Properties
Constants
parse()
$pos
$query
$len
$table_tokens
No constants found
No protected methods found
No protected properties found
N/A
has_next_token()
get_next_token()
No private properties found
N/A

Properties

$pos

$pos : 

Type

$query

$query : 

Type

$len

$len : 

Type

$table_tokens

$table_tokens : 

Type

Methods

parse()

parse(string  $query) : array

parse a query and return an array of table names from it.

Parameters

string $query

the sql query

Returns

array —

the list of table names.

has_next_token()

has_next_token() : boolean

return true if we're not at the end of the string yet.

Returns

boolean —

true if there are more tokens to read

get_next_token()

get_next_token() : string

returns the next whitespace separated string of characters

Returns

string —

the token value