Fixes #161, DQL : added support for EJB 3 -style JOIN syntax
This commit is contained in:
parent
7c47b78550
commit
f40601fefe
@ -11,11 +11,32 @@ class Doctrine_Query_From extends Doctrine_Query_Part {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
final public function parse($str) {
|
final public function parse($str) {
|
||||||
foreach(Doctrine_Query::bracketExplode(trim($str),",", "(",")") as $reference) {
|
$str = trim($str);
|
||||||
$reference = trim($reference);
|
$parts = Doctrine_Query::bracketExplode($str, 'JOIN');
|
||||||
$a = explode(".",$reference);
|
|
||||||
$field = array_pop($a);
|
$operator = false;
|
||||||
$table = $this->query->load($reference);
|
$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("QueryMultiJoinTestCase.php");
|
||||||
require_once("QueryReferenceModelTestCase.php");
|
require_once("QueryReferenceModelTestCase.php");
|
||||||
require_once("QueryWhereTestCase.php");
|
require_once("QueryWhereTestCase.php");
|
||||||
|
require_once("QueryFromTestCase.php");
|
||||||
require_once("QueryConditionTestCase.php");
|
require_once("QueryConditionTestCase.php");
|
||||||
require_once("QueryComponentAliasTestCase.php");
|
require_once("QueryComponentAliasTestCase.php");
|
||||||
require_once("QuerySubqueryTestCase.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_Where_TestCase());
|
||||||
|
|
||||||
|
$test->addTestCase(new Doctrine_Query_From_TestCase());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user