@@ -393,7 +393,9 @@ private function conditionIs($key, $condition, $combine)
393393
394394 private function retrieveConditions ($ whereConditions )
395395 {
396- $ whereClause = [];
396+ $ whereConditions = flattenWhereConditions ($ whereConditions );
397+ $ whereKey = [];
398+ $ whereValue = [];
397399 $ operator = [];
398400 $ extra = [];
399401 $ combiner = [];
@@ -402,23 +404,27 @@ private function retrieveConditions($whereConditions)
402404 $ operator [] = (isset ($ checkFields [1 ])) ? $ checkFields [1 ] : '' ;
403405 if (empty ($ checkFields [1 ])) {
404406 $ this ->clearPrepare ();
405- return [[], [], [], [], []];
407+ return [[], [], [], [], [], [] ];
406408 }
407409
408410 if (\strtoupper ($ checkFields [1 ]) == 'IN ' ) {
409- $ whereClause [$ checkFields [0 ]] = \array_slice ((array ) $ checkFields , 2 );
411+ $ whereKey [] = $ checkFields [0 ];
412+ $ whereValue [] = \array_slice ((array ) $ checkFields , 2 );
410413 $ combiner [] = \_AND ;
411414 $ group [] = null ;
412415 $ extra [] = null ;
413416 } else {
414- $ whereClause [(isset ($ checkFields [0 ])) ? $ checkFields [0 ] : '1 ' ] = (isset ($ checkFields [2 ])) ? $ checkFields [2 ] : '' ;
415- $ combiner [] = (isset ($ checkFields [3 ])) ? $ checkFields [3 ] : \_AND ;
416- $ group [] = (isset ($ checkFields [4 ])) ? $ checkFields [4 ] : null ;
417- $ extra [] = (isset ($ checkFields [5 ])) ? $ checkFields [5 ] : null ;
417+ if (!empty ($ checkFields [0 ])) {
418+ $ whereKey [] = $ checkFields [0 ];
419+ $ whereValue [] = (isset ($ checkFields [2 ])) ? $ checkFields [2 ] : '' ;
420+ $ combiner [] = (isset ($ checkFields [3 ])) ? $ checkFields [3 ] : \_AND ;
421+ $ group [] = (isset ($ checkFields [4 ])) ? $ checkFields [4 ] : null ;
422+ $ extra [] = (isset ($ checkFields [5 ])) ? $ checkFields [5 ] : null ;
423+ }
418424 }
419425 }
420426
421- return [$ operator , $ whereClause , $ combiner , $ extra , $ group ];
427+ return [$ operator , $ whereKey , $ whereValue , $ combiner , $ extra , $ group ];
422428 }
423429
424430 private function processConditions ($ column , $ condition , $ value , $ valueOrCombine , $ extraCombine , $ whereGroup )
@@ -465,7 +471,6 @@ public function whereGroup(...$whereConditions)
465471
466472 public function where (...$ whereConditions )
467473 {
468- $ whereConditions = (!empty ($ whereConditions [0 ]) && is_array ($ whereConditions [0 ])) ? $ whereConditions [0 ] : $ whereConditions ;
469474
470475 if (empty ($ whereConditions ))
471476 return false ;
@@ -478,22 +483,22 @@ public function where(...$whereConditions)
478483 if (\is_string ($ whereConditions [0 ]) && \strpos ($ whereConditions [0 ], $ whereOrHaving ) !== false )
479484 return $ whereConditions [0 ];
480485
481- list ($ operator , $ whereClause , $ combiner , $ extra , $ group ) = $ this ->retrieveConditions ($ whereConditions );
486+ list ($ operator , $ whereKeys , $ whereValues , $ combiner , $ extra , $ group ) = $ this ->retrieveConditions ($ whereConditions );
482487 if (empty ($ operator ))
483488 return false ;
484489
485490 $ where = '1 ' ;
486- if (!isset ( $ whereClause [ ' 1 ' ] )) {
491+ if (!empty ( $ whereKeys )) {
487492 $ this ->whereSQL = '' ;
488493 $ i = 0 ;
489- foreach ($ whereClause as $ key => $ val ) {
494+ foreach ($ whereKeys as $ key ) {
490495 $ isCondition = \strtoupper ($ operator [$ i ]);
491496 $ combine = $ combiner [$ i ];
492497 $ this ->combineWith = \_AND ;
493498 if (\in_array (\strtoupper ($ combine ), \_COMBINERS ) || isset ($ extra [$ i ]))
494499 $ this ->combineWith = isset ($ extra [$ i ]) ? $ combine : \strtoupper ($ combine );
495500
496- if ($ this ->processConditions ($ key , $ isCondition , $ val , $ this ->combineWith , $ extra [$ i ], $ group [$ i ]) === false )
501+ if ($ this ->processConditions ($ key , $ isCondition , $ whereValues [ $ i ] , $ this ->combineWith , $ extra [$ i ], $ group [$ i ]) === false )
497502 return false ;
498503
499504 $ i ++;
0 commit comments