@@ -19,7 +19,8 @@ class ezQuery implements ezQueryInterface
1919 private $ combineWith = null ;
2020
2121 public function __construct ()
22- { }
22+ {
23+ }
2324
2425 public static function clean ($ string )
2526 {
@@ -282,7 +283,7 @@ public function fullJoin(
282283 * @param string $condition -
283284 *
284285 * @return bool|string JOIN sql statement, false for error
285- */
286+ */
286287 private function joining (
287288 String $ type = \_INNER ,
288289 string $ leftTable = null ,
@@ -389,29 +390,34 @@ private function conditionIs($key, $condition, $combine)
389390
390391 private function retrieveConditions ($ whereConditions )
391392 {
392- $ whereClause = [];
393+ $ whereKey = [];
394+ $ whereValue = [];
393395 $ operator = [];
394396 $ extra = [];
395397 $ combiner = [];
396398 foreach ($ whereConditions as $ checkFields ) {
397399 $ operator [] = (isset ($ checkFields [1 ])) ? $ checkFields [1 ] : '' ;
398400 if (empty ($ checkFields [1 ])) {
399401 $ this ->clearPrepare ();
400- return [[], [], [], []];
402+ return [[], [], [], [], [] ];
401403 }
402404
403405 if (\strtoupper ($ checkFields [1 ]) == 'IN ' ) {
404- $ whereClause [$ checkFields [0 ]] = \array_slice ((array ) $ checkFields , 2 );
406+ $ whereKey [] = $ checkFields [0 ];
407+ $ whereValue [] = \array_slice ((array ) $ checkFields , 2 );
405408 $ combiner [] = \_AND ;
406409 $ extra [] = null ;
407410 } else {
408- $ whereClause [(isset ($ checkFields [0 ])) ? $ checkFields [0 ] : '1 ' ] = (isset ($ checkFields [2 ])) ? $ checkFields [2 ] : '' ;
409- $ combiner [] = (isset ($ checkFields [3 ])) ? $ checkFields [3 ] : \_AND ;
410- $ extra [] = (isset ($ checkFields [4 ])) ? $ checkFields [4 ] : null ;
411+ if (isset ($ checkFields [0 ])) {
412+ $ whereKey [] = $ checkFields [0 ];
413+ $ whereValue [] = (isset ($ checkFields [2 ])) ? $ checkFields [2 ] : '' ;
414+ $ combiner [] = (isset ($ checkFields [3 ])) ? $ checkFields [3 ] : \_AND ;
415+ $ extra [] = (isset ($ checkFields [4 ])) ? $ checkFields [4 ] : null ;
416+ }
411417 }
412418 }
413419
414- return [$ operator , $ whereClause , $ combiner , $ extra ];
420+ return [$ operator , $ whereKey , $ whereValue , $ combiner , $ extra ];
415421 }
416422
417423 private function processConditions ($ column , $ condition , $ value , $ valueOrCombine , $ extraCombine )
@@ -445,22 +451,22 @@ public function where(...$whereConditions)
445451 if (\is_string ($ whereConditions [0 ]) && \strpos ($ whereConditions [0 ], $ whereOrHaving ) !== false )
446452 return $ whereConditions [0 ];
447453
448- list ($ operator , $ whereClause , $ combiner , $ extra ) = $ this ->retrieveConditions ($ whereConditions );
454+ list ($ operator , $ whereKeys , $ whereValues , $ combiner , $ extra ) = $ this ->retrieveConditions ($ whereConditions );
449455 if (empty ($ operator ))
450456 return false ;
451457
452458 $ where = '1 ' ;
453- if (!isset ( $ whereClause [ ' 1 ' ] )) {
459+ if (!empty ( $ whereKeys )) {
454460 $ this ->whereSQL = '' ;
455461 $ i = 0 ;
456- foreach ($ whereClause as $ key => $ val ) {
462+ foreach ($ whereKeys as $ key ) {
457463 $ isCondition = \strtoupper ($ operator [$ i ]);
458464 $ combine = $ combiner [$ i ];
459465 $ this ->combineWith = \_AND ;
460466 if (\in_array (\strtoupper ($ combine ), \_COMBINERS ) || isset ($ extra [$ i ]))
461467 $ this ->combineWith = isset ($ extra [$ i ]) ? $ combine : \strtoupper ($ combine );
462468
463- if ($ this ->processConditions ($ key , $ isCondition , $ val , $ this ->combineWith , $ extra [$ i ]) === false )
469+ if ($ this ->processConditions ($ key , $ isCondition , $ whereValues [ $ i ] , $ this ->combineWith , $ extra [$ i ]) === false )
464470 return false ;
465471
466472 $ i ++;
0 commit comments