From 618a561c71c96adb720b86aa1450885bd913c245 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 30 Jun 2014 11:14:37 -0400 Subject: [PATCH] Fix minor issue of where clause disappearing after a number of joins --- core/abstract/abstract_query_builder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/abstract/abstract_query_builder.php b/core/abstract/abstract_query_builder.php index d095f2b..83102b3 100644 --- a/core/abstract/abstract_query_builder.php +++ b/core/abstract/abstract_query_builder.php @@ -376,14 +376,15 @@ abstract class Abstract_Query_Builder { $item .= (count($f_array) === 1) ? '=?' : " {$f_array[1]} ?"; // Get the type of the first item in the query map - $first_item = end($this->query_map); + $first_item = current($this->query_map); + $last_item = end($this->query_map); // Determine the correct conjunction - if (empty($this->query_map)) + if (empty($this->query_map) || stripos($first_item['conjunction'], 'JOIN') !== FALSE) { $conj = "\nWHERE "; } - elseif ($first_item['type'] === 'group_start') + elseif ($last_item['type'] === 'group_start') { $conj = ''; }