Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated select, order_by and where(), updated tests
- Loading branch information
Martin Rusev
committed
Jan 20, 2010
1 parent
03e0ad7
commit 33513ce
Showing
25 changed files
with
1,216 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<buildpath> | ||
<buildpathentry kind="src" path=""/> | ||
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/> | ||
</buildpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
class Crystal_Parser_Exception extends Crystal_Exception{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
class Crystal_Parser_String | ||
{ | ||
|
||
static function parse($string) | ||
{ | ||
|
||
/** Check for comma **/ | ||
$comma = strpos($string, ','); | ||
|
||
/** Multiple params **/ | ||
if($comma != False) | ||
{ | ||
$params = explode(',', $string); | ||
|
||
/** Check every param for special exceptions ':' **/ | ||
foreach($params as $k => $v) | ||
{ | ||
/** Check for colon **/ | ||
$colon = strpos($v, ':'); | ||
if($colon != False) | ||
{ | ||
|
||
$params[$k] = self::_process_string_with_colon($v); | ||
|
||
|
||
} | ||
else | ||
{ | ||
$params[$k] = trim($v); | ||
} | ||
|
||
} | ||
|
||
return $params; | ||
|
||
} | ||
else | ||
{ | ||
/** Single column **/ | ||
$colon = strpos($string, ':'); | ||
|
||
if($colon != False) | ||
{ | ||
$formated_string = self::_process_string_with_colon($string); | ||
|
||
return $formated_string; | ||
} | ||
else | ||
{ | ||
return trim($string); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
private function _process_string_with_colon($string) | ||
{ | ||
|
||
/** Explode params to array | ||
* | ||
* $explode_params[0] is the column name | ||
* $explode_params[1] is the special character : | ||
* $explode_params[2] is the value | ||
* | ||
*/ | ||
$explode_params = explode(' ', trim($string)); | ||
|
||
$params = array(); | ||
$params['column'] = trim($explode_params[0]); | ||
$params['value'] = trim($explode_params[2]); | ||
|
||
|
||
/** Now checking for special params **/ | ||
$as = strpos($string, ':as'); | ||
|
||
if($as != False) | ||
{ | ||
$params['param'] = 'AS'; | ||
} | ||
else | ||
{ | ||
$params['param'] = '='; | ||
} | ||
|
||
return $params; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.