Class QueryTableParser

Description

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`

  • author: Gavin Towey <gavin@box.com>
  • todo: handle table names with spaces wrapped in backticks or quotes
  • todo: stop parsing early if possible -- after the JOIN clause (if any)
  • todo: ignore token values inside string literals or backticks
  • license: Please

Located in /QueryTableParser.php (line 22)


	
			
Variable Summary
mixed $len
mixed $pos
mixed $query
Method Summary
array parse (string $query)
Variables
mixed $len (line 26)
  • access: public
mixed $pos (line 24)
  • access: public
mixed $query (line 25)
  • access: public
mixed $table_tokens = array(
'from',
'join',
'update',
'into',
)
(line 27)
  • access: public
Methods
parse (line 40)

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

  • return: the list of table names.
  • access: public
array parse (string $query)
  • string $query: the sql query

Documentation generated on Mon, 12 Mar 2012 11:59:41 -0700 by phpDocumentor 1.4.4