File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ class SimplePDOQueryBuilder
3939 */
4040 protected $ joins = [];
4141
42+ /**
43+ * @var array
44+ */
45+ protected $ leftJoins = [];
46+
4247 /**
4348 * @var
4449 */
@@ -157,9 +162,9 @@ public function from($from)
157162 public function leftJoin ($ leftJoin , $ condition = '' )
158163 {
159164 if ($ leftJoin instanceof SimplePDOQueryBuilder) {
160- $ this ->joins [] = "\n LEFT JOIN ( {$ leftJoin ->getSql ()} ) as {$ leftJoin ->getAlias ()} ON $ condition " ;
165+ $ this ->leftJoins [] = "\n LEFT JOIN ( {$ leftJoin ->getSql ()} ) as {$ leftJoin ->getAlias ()} ON $ condition " ;
161166 } else {
162- $ this ->joins [] = "\n LEFT JOIN " . $ leftJoin . ($ condition ? ' ON ' . $ condition : '' );
167+ $ this ->leftJoins [] = "\n LEFT JOIN " . $ leftJoin . ($ condition ? ' ON ' . $ condition : '' );
163168 }
164169 return $ this ;
165170 }
@@ -257,6 +262,9 @@ public function getSql()
257262 if (!empty ($ this ->joins )) {
258263 $ query .= implode (' ' , $ this ->joins );
259264 }
265+ if (!empty ($ this ->leftJoins )) {
266+ $ query .= implode (' ' , $ this ->leftJoins );
267+ }
260268 if (!empty ($ this ->where )) {
261269 $ query .= "\n WHERE " . implode (" AND " , $ this ->where );
262270 }
@@ -293,6 +301,14 @@ public function resetHaving()
293301 $ this ->having = [];
294302 }
295303
304+ /**
305+ *
306+ */
307+ public function resetLeftJoins ()
308+ {
309+ $ this ->leftJoins = [];
310+ }
311+
296312 /**
297313 * @param $limit
298314 * @param $offset
Original file line number Diff line number Diff line change 44 "description" : " Simple PDO Query Builder" ,
55 "keywords" : [" pdo" , " query builder" ],
66 "license" : " MIT" ,
7- "version" : " 1.3.2 " ,
7+ "version" : " 1.3.3 " ,
88 "authors" : [
99 {
1010 "name" : " Vasily Sokolov" ,
You can’t perform that action at this time.
0 commit comments