From 286cd7bacdfed3bfeaf1bfd46889329bc03dc637 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 19 May 2010 16:38:51 +0200 Subject: [PATCH] DibiFluent: implemented clause auto-switch for 'JOIN', 'INNER JOIN', 'LEFT JOIN' --- dibi/libs/DibiFluent.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dibi/libs/DibiFluent.php b/dibi/libs/DibiFluent.php index f768be30..2f35d2ae 100644 --- a/dibi/libs/DibiFluent.php +++ b/dibi/libs/DibiFluent.php @@ -72,6 +72,14 @@ class DibiFluent extends DibiObject implements IDataSource 'INTO' => FALSE, ); + /** @var array clauses */ + public static $clauseSwitches = array( + 'JOIN' => 'FROM', + 'INNER JOIN' => 'FROM', + 'LEFT JOIN' => 'FROM', + 'RIGHT JOIN' => 'FROM', + ); + /** @var DibiConnection */ private $connection; @@ -119,6 +127,11 @@ class DibiFluent extends DibiObject implements IDataSource $this->command = $clause; } + // auto-switch to a clause + if (isset(self::$clauseSwitches[$clause])) { + $this->cursor = & $this->clauses[self::$clauseSwitches[$clause]]; + } + // special types or argument if (count($args) === 1) { $arg = $args[0];