PHP Class PHPSQLParser\PHPSQLParser

Author: Justin Swanhart ([email protected])
Author: AndrĂ© Rothe ([email protected])
Show file Open project: greenlion/php-sql-parser Class Usage Examples

Public Properties

Property Type Description
$parsed

Public Methods

Method Description
__construct ( String | boolean $sql = false, boolean $calcPositions = false, array $options = [] ) Constructor. It simply calls the parse() function.
addCustomFunction ( String $token ) : null Add a custom function to the parser. no return value
getCustomFunctions ( ) : array Returns the list of custom functions
parse ( String $sql, boolean $calcPositions = false ) : array It parses the given SQL statement and generates a detailled output array for every part of the statement. The method can also generate [position] fields within the output, which hold the character position for every statement part. The calculation of the positions needs some time, if you don't need positions in your application, set the parameter to false.
removeCustomFunction ( String $token ) : null Remove a custom function from the parser. no return value

Method Details

__construct() public method

Use the public variable $parsed to get the output.
public __construct ( String | boolean $sql = false, boolean $calcPositions = false, array $options = [] )
$sql String | boolean The SQL statement.
$calcPositions boolean True, if the output should contain [position], false otherwise.
$options array

addCustomFunction() public method

Add a custom function to the parser. no return value
public addCustomFunction ( String $token ) : null
$token String The name of the function to add
return null

getCustomFunctions() public method

Returns the list of custom functions
public getCustomFunctions ( ) : array
return array Returns an array of all custom functions

parse() public method

It parses the given SQL statement and generates a detailled output array for every part of the statement. The method can also generate [position] fields within the output, which hold the character position for every statement part. The calculation of the positions needs some time, if you don't need positions in your application, set the parameter to false.
public parse ( String $sql, boolean $calcPositions = false ) : array
$sql String The SQL statement.
$calcPositions boolean True, if the output should contain [position], false otherwise.
return array An associative array with all meta information about the SQL statement.

removeCustomFunction() public method

Remove a custom function from the parser. no return value
public removeCustomFunction ( String $token ) : null
$token String The name of the function to remove
return null

Property Details

$parsed public property

public $parsed