|
Doctrine 1.2.4
|
Public Member Functions | |
| bracketExplode ($str, $d= ' ', $e1= '(', $e2= ')') | |
| bracketTrim ($str, $e1= '(', $e2= ')') | |
| clauseExplode ($str, array $d, $e1= '(', $e2= ')') | |
| quotedStringExplode ($str) | |
| quoteExplode ($str, $d= ' ') | |
| sqlExplode ($str, $d= ' ', $e1= '(', $e2= ')') | |
| tokenizeQuery ($query) | |
Definition at line 35 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::bracketExplode | ( | $str, | |
$d = ' ', |
|||
$e1 = '(', |
|||
$e2 = ')' |
|||
| ) |
Explodes a sql expression respecting bracket placement.
This method transform a sql expression in an array of simple clauses, while observing the parentheses precedence.
Note: bracketExplode always trims the returned pieces
$str = (age < 20 AND age > 18) AND email LIKE 'John@example.com' $clauses = $tokenizer->bracketExplode($str, ' AND ', '(', ')'); // array("(age < 20 AND age > 18)", "email LIKE 'John@example.com'")
| string | $str | String to be bracket exploded |
| string | $d | Delimeter which explodes the string |
| string | $e1 | First bracket, usually '(' |
| string | $e2 | Second bracket, usually ')' |
Definition at line 152 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::bracketTrim | ( | $str, | |
$e1 = '(', |
|||
$e2 = ')' |
|||
| ) |
Trims brackets from string
| string | $str | String to remove the brackets |
| string | $e1 | First bracket, usually '(' |
| string | $e2 | Second bracket, usually ')' |
Definition at line 122 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::clauseExplode | ( | $str, | |
| array | $d, | ||
$e1 = '(', |
|||
$e2 = ')' |
|||
| ) |
Explodes a string into array using custom brackets and quote delimeters Each array element is a array of length 2 where the first entry contains the term, and the second entry contains the corresponding delimiter
example:
parameters: $str = "(age < 20 AND age > 18) AND name LIKE 'John'+' Doe'" $d = array(' ', '+') $e1 = '(' $e2 = ')'
would return an array: array( array('(age < 20 AND age > 18)', ' '), array('AND', ' '), array('name', ' '), array('LIKE', ' '), array('John', '+'), array(' Doe', '') );
| string | $str | String to be clause exploded |
| string | $d | Delimeter which explodes the string |
| string | $e1 | First bracket, usually '(' |
| string | $e2 | Second bracket, usually ')' |
Definition at line 285 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::quotedStringExplode | ( | $str | ) |
Explodes the given string by <quoted words>="">
example:
paramters: $str ="'a' AND name = 'John O\'Connor'"
returns array("", "'a'", " AND name = ", "'John O\'Connor'")
Note the trailing empty string. In the result, all even elements are quoted strings.
| $str | the string to split |
Definition at line 513 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::quoteExplode | ( | $str, | |
$d = ' ' |
|||
| ) |
Explode quotes from string
Note: quoteExplode always trims the returned pieces
example:
parameters: $str = email LIKE 'John@example.com' $d = ' LIKE '
would return an array: array("email", "LIKE", "'John@example.com'")
| string | $str | String to be quote exploded |
| string | $d | Delimeter which explodes the string |
Definition at line 191 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::sqlExplode | ( | $str, | |
$d = ' ', |
|||
$e1 = '(', |
|||
$e2 = ')' |
|||
| ) |
Explodes a string into array using custom brackets and quote delimeters
Note: sqlExplode trims all returned parts
example:
parameters: $str = "(age < 20 AND age > 18) AND name LIKE 'John Doe'" $d = ' ' $e1 = '(' $e2 = ')'
would return an array: array( '(age < 20 AND age > 18)', 'name', 'LIKE', 'John Doe' );
| string | $str | String to be SQL exploded |
| string | $d | Delimeter which explodes the string |
| string | $e1 | First bracket, usually '(' |
| string | $e2 | Second bracket, usually ')' |
Definition at line 239 of file Tokenizer.php.
| Doctrine_Query_Tokenizer::tokenizeQuery | ( | $query | ) |
Splits the given dql query into an array where keys represent different query part names and values are arrays splitted using sqlExplode method
example:
parameter: $query = "SELECT u.* FROM User u WHERE u.name LIKE ?" returns: array( 'select' => array('u.*'), 'from' => array('User', 'u'), 'where' => array('u.name', 'LIKE', '?') );
| string | $query | DQL query |
| Doctrine_Query_Exception | If some generic parsing error occurs |
Definition at line 59 of file Tokenizer.php.