- Fixed a bug with the IN query
This commit is contained in:
		
							parent
							
								
									902167c2ed
								
							
						
					
					
						commit
						5ef20533b2
					
				@ -110,11 +110,11 @@ class Where extends Fragment {
 | 
				
			|||||||
            protected function operator() : string
 | 
					            protected function operator() : string
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( is_array($this->value) ) {
 | 
					                if ( is_array($this->value) ) {
 | 
				
			||||||
                    return (in_array($this->operator, [ '!=', '<>' ]) ? Where::CONDITION_NOT . " " : "") . Where::COMPARISON_IN;
 | 
					                    return Where::COMPARISON_IN;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # whitelisting operators
 | 
					                # whitelisting operators
 | 
				
			||||||
                return in_array(strtoupper($this->operator), [ '=', '!=', '>', '>=', '<', '<=', '<>', 'LIKE', 'IS', 'IS NOT', 'REGEXP' ]) ? $this->operator : "=";
 | 
					                return in_array(strtoupper($this->operator), [ '=', '!=', '>', '>=', '<', '<=', '<>', 'LIKE', 'IS', 'IS NOT', 'REGEXP', 'IN' ]) ? $this->operator : "=";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            protected function value()
 | 
					            protected function value()
 | 
				
			||||||
 | 
				
			|||||||
@ -95,14 +95,14 @@ trait ConditionTrait
 | 
				
			|||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function in($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
 | 
					    public function in($field, $value, string $operator = Query\Where::COMPARISON_IN) : self
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->queryBuilder->where($field, $value, $operator);
 | 
					        $this->queryBuilder->where($field, $value, $operator);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function orIn($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self
 | 
					    public function orIn($field, $value, string $operator = Query\Where::COMPARISON_IN) : self
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR);
 | 
					        $this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -111,14 +111,14 @@ trait ConditionTrait
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function notIn($field, $value) : self
 | 
					    public function notIn($field, $value) : self
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->queryBuilder->where($field, $value, Query\Where::OPERATOR_NOT_EQUAL);
 | 
					        $this->queryBuilder->where($field, $value, Query\Where::COMPARISON_IN, true);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function orNotIn($field, $value) : self
 | 
					    public function orNotIn($field, $value) : self
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->orNot($field, $value, Query\Where::OPERATOR_NOT_EQUAL, Query\Where::CONDITION_OR, true);
 | 
					        return $this->orNot($field, $value, Query\Where::COMPARISON_IN, Query\Where::CONDITION_OR, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function like($field, $value) : self
 | 
					    public function like($field, $value) : self
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user