Commit f40601fe authored by zYne's avatar zYne

Fixes #161, DQL : added support for EJB 3 -style JOIN syntax

parent 7c47b785
......@@ -11,11 +11,32 @@ class Doctrine_Query_From extends Doctrine_Query_Part {
* @return void
*/
final public function parse($str) {
foreach(Doctrine_Query::bracketExplode(trim($str),",", "(",")") as $reference) {
$reference = trim($reference);
$a = explode(".",$reference);
$field = array_pop($a);
$table = $this->query->load($reference);
$str = trim($str);
$parts = Doctrine_Query::bracketExplode($str, 'JOIN');
$operator = false;
$last = '';
foreach($parts as $k => $part) {
$part = trim($part);
$e = explode(" ", $part);
if(end($e) == 'INNER' || end($e) == 'LEFT')
$last = array_pop($e);
$part = implode(" ", $e);
foreach(Doctrine_Query::bracketExplode($part, ',') as $reference) {
$reference = trim($reference);
$e = explode('.', $reference);
if($operator) {
$reference = array_shift($e).$operator.implode('.', $e);
}
$table = $this->query->load($reference);
}
$operator = ($last == 'INNER') ? ':' : '.';
}
}
......
......@@ -33,6 +33,7 @@ require_once("QueryLimitTestCase.php");
require_once("QueryMultiJoinTestCase.php");
require_once("QueryReferenceModelTestCase.php");
require_once("QueryWhereTestCase.php");
require_once("QueryFromTestCase.php");
require_once("QueryConditionTestCase.php");
require_once("QueryComponentAliasTestCase.php");
require_once("QuerySubqueryTestCase.php");
......@@ -126,6 +127,8 @@ $test->addTestCase(new Doctrine_QueryTestCase());
$test->addTestCase(new Doctrine_Query_Where_TestCase());
$test->addTestCase(new Doctrine_Query_From_TestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment