Returns the where in array as a WHERE IN string

@return string WHERE string
502130
private function getWhereInString()
    {
        // String holder
        $string = '';

        // If there are not where in conditions, return empty
        if (!count($this->whereIn)) {
            return $string;
        }

        // Iterate where creating the full conditions
        foreach ($this->whereIn as $where) {
            $string .= ' AND ' . $where['column'] . ' IN (' . implode(', ', $where['values']) . ')';
        }

        // Return complete where in string
        return $string;
    }
1017198
private function getSelect(array $where): string
    {
        // Current table
        $table = $this->getCollection();

        // Generate where line
        $whereDetails = !empty($where)
            ? ' WHERE ' . $this->genWhere($where)
            : '';

        return "SELECT * FROM $table $whereDetails";
    }
1147594
function orwhere($where)
    {
        $args = func_get_args();
        if (count($args) == 1)
        {
            $where = $args[0];
        }
        else
        {
            list($field, $expr, $value) = $args;
            $where = '`'.str_replace('`', '', $field).'`' . $this->db->quote($expr) . " '".$this->db->quote($value)."'";
        }

        if ($this->where == "")
        {
            $this->where = "where " . $where;
        }
        else
        {
            $this->where = $this->where . " or " . $where;
        }
    }
1115987
protected function getWhereSql(array $whereArray = null, $cnt = 0): string
    {
    	if ($this->bindings === null) {
    		$this->bindings = new Bindings();
	    }

        $query = '';

        if ($whereArray === null) {
            $whereArray = $this->where;
        }

        foreach ($whereArray as $index => $where) {
            if ($index > 0) {
                $query .= "\t{$where['link']}";
            }

            $field = $where['field'];
            $value = $where['value'];

            if (gettype($field) == 'object' && $value === null) {
                // function or instance of self is passed, do something

                $q = ($field instanceof self) ? clone $field : $field(new self());
                if ($q === null) {
                    throw new DbException('Can not build query, statement\'s where function didn\'t return anything');
                }

                $whereSql = trim($q->getWhereSql(null, $cnt++));
                $whereSql = str_replace("\n", ' ', $whereSql);
                $whereSql = str_replace("\t", '', $whereSql);

                $query .= " ({$whereSql})\n";

                /*
                foreach ($q->getBindings() as $k => $v) {
                    $this->bindings[$k] = $v;
                }
                */

                $this->bindings->addBindingsFromInstance($q->getBindings());

            } else if ($value instanceof Expr) {
                $query .= " ({$field} {$where['operator']} {$value})\n";

            } else if (is_array($value)) {

                switch ($where['operator']) {
                    case 'BETWEEN':
                    case 'NOT BETWEEN':
                        $query .= " ({$field} {$where['operator']} ";

                        if ($value[0] instanceof Expr) {
                            $query .= $value[0];
                        } else {
                            //$key = $this->bind($field, $value[0]);
	                        $key = $this->bindings->makeAndSet($field, $value[0]);
                            $query .= ":{$key}";
                        }

                        $query .= ' AND ';

                        if ($value[1] instanceof Expr) {
                            $query .= $value[1];
                        } else {
                            //$key = $this->bind($field, $value[1]);
	                        $key = $this->bindings->makeAndSet($field, $value[1]);
                            $query .= ":{$key}";
                        }

                        $query .= ")\n";
                        break;

                    case 'IN':
                    case 'NOT IN':
                        $query .= " ({$field} {$where['operator']} (";

                        foreach ($value as $val) {
                            //$key = $this->bind($field, $val);
	                        $key = $this->bindings->makeAndSet($field, $val);
                            $query .= ":{$key},";
                        }

                        $query = substr($query, 0, -1);
                        $query .= "))\n";
                        break;

                    // default: nothing by default
                }

            } else {
                //$key = $this->bind($field, $where['value']);
	            $key = $this->bindings->makeAndSet($field, $where['value']);
                $query .= " ({$field} {$where['operator']} :{$key})\n";

            }

        }

        return $query;
    }
431286
public function orWhere($wheres = array())
		{
			if (count($wheres) > 0) {
				if ( ! isset($this->wheres['$or']) or ! Arrays::is($this->wheres['$or'])) {
					$this->wheres['$or'] = array();
				}

				foreach ($wheres as $wh => $val) {
					$this->wheres['$or'][] = array($wh => $val);
				}
			}

			return $this;
		}
814862
protected function where(array $where): string
	{
		if(is_array($where['column']))
		{
			$column = '(' . $this->columns($where['column'], false) . ')';

			$value = is_array($where['value']) ? '(' . $this->params($where['value']) . ')' : $this->param($where['value']);

			return $column . ' ' . $where['operator'] . ' ' . $value;
		}

		return $this->column($where['column']) . ' ' . $where['operator'] . ' ' . $this->param($where['value']);
	}
635440
public function findWhere(array $where, $columns = ['*'])
    {
        $this->newQuery();

        foreach ($where as $field => $value) {
            if (is_array($value)) {
                list($field, $condition, $val) = $value;
                $this->query->where($field, $condition, $val);
            }
            else {
                $this->query->where($field, '=', $value);
            }
        }

        return $this->query->get($columns);
    }
904413
public function getQueryString()
    {
        $query = [];
        if (!empty($this->pagination)) {
            $query[self::PARAM_PAGINATION] = $this->pagination;
        }
        if (!empty($this->filters)) {
            $query[self::PARAM_FILTERING] = $this->filters;
        }
        foreach ($this->fields as $modelType => $fields) {
            $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields);
        }
        $sort = [];
        foreach ($this->sorting as $key => $direction) {
            $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key);
        }
        if (!empty($sort)) {
            $query[self::PARAM_SORTING] = implode(',', $sort);
        }
        return http_build_query($query);
    }
865326
public function toString()
	{
		// Build the actual query
		if (is_object($this->statement))
		{
			$query = $this->interpolate($this->statement->queryString, $this->bindings);
		}
		else
		{
			$query = $this->statement;
		}

		return $query;
	}
608436
public function where_in($field = '', $in = array())
	{
		$this->_where_init($field);
		$this->wheres[$field]['$in'] = $in;
		return $this;
	}
945653
public function getListFilter()
    {
        if ($this->_aListFilter === null) {
            $this->_aListFilter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("where");
        }

        return $this->_aListFilter;
    }
1117110
public function GetCountWhere($Where = FALSE) {
      if (is_array($Where))
         $this->SQL->Where($Where);
         
      return $this->SQL->Select('CommentID', 'count', 'CountComments')
         ->From('Comment')
         ->Get()
         ->FirstRow()
         ->CountComments;
   }
242498
private function buildWhere()
    {
        $query = array();

        // Make sure there's something to do
        if (isset($this->query['where']) and count($this->query['where'])) {
            foreach ($this->query['where'] as $group => $conditions) {
                $group = array(); // Yes, because the $group above is not used, get over it.
                foreach ($conditions as $condition => $value) {
                    // Get column name
                    $cond = explode(" ", $condition);
                    $column = str_replace('`', '', $cond[0]);
                    $safeColumn = $this->columnName($column);

                    // Make the column name safe
                    $condition = str_replace($column, $safeColumn, $condition);

                    // Add value to the bind queue
                    $valueBindKey = str_replace(array('.', '`'), array('_', ''), $safeColumn);

                    if (!empty($value) or $value !== null) {
                        $this->valuesToBind[$valueBindKey] = $value;
                    }

                    // Add condition to group
                    $group[] = str_replace("?", ":{$valueBindKey}", $condition);
                }

                // Add the group
                $query[] = "(" . implode(" AND ", $group) . ")";
            }

            // Return
            return "WHERE " . implode(" OR ", $query);
        }
    }
109623
public function get()
    {
        $sql = "SELECT * FROM `$this->_table` ";

        $this->_param_list = array();

        if (!empty($this->_where_list)) {
            $sql .= "WHERE ";
            $first = true;
            foreach ($this->_where_list as $field_name => $field_settings) {
                $type          = isset($field_settings['type']) ? $field_settings['type'] : false;
                $field_value   = $field_settings['value'];
                $field_connect = isset($field_settings['op']) ? $field_settings['op'] : ' AND ';

                switch ($type) {
                    case 'like':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name like '%:$field_name%'";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    case 'in':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name IN (:$field_name)";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    default:
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name = :$field_name";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                }

                // we can assume that after the first iteration it's false
                $first = false;
            }
        }
        unset($field_connect, $field_name, $field_value, $type, $field_settings);

        if (!empty($this->_group)) {
            if (is_array($this->_group)) {
                $this->_limit = implode(',', $this->_group_by);
            }

            $sql .= ' GROUP BY ' . $this->_group_by;
        }

        if (!empty($this->_limit)) {
            if (is_array($this->_limit)) {
                $this->_limit = implode(',', $this->_limit);
            }

            $sql .= ' LIMIT ' . $this->_limit;
        }

        $this->last_sql = $sql;

        $this->__init_database();

        $stmt = $this->db->prepare($sql);
        // set the prepared statement
        for ($i = 0, $c = count($this->_param_list); $i < $c; $i++) {
            $stmt->bindParam($this->_param_list[$i][0], $this->_param_list[$i][1]);
        }


        if (!$stmt->execute()) return;

        $this->result = $stmt->fetchAll(MySQL::FETCH_OBJ);
    }
980698
protected function parseSearch()
    {
        return implode(' ', array_map(function ($key, $val) {
            if (is_null($val)) {
                return strtoupper($key);
            }
            return sprintf('%s %s', strtoupper($key), $val);
        }, array_keys($this->where), array_values($this->where)));
    }
106884
public function where($arguments)
	{

		//put this in try...catch block for better error handling
		try{

			//throw exception if argument pairs do ot match
			if ( is_float( sizeof($arguments) / 2 ) ) 
			{
				//throw exception
				throw new MySQLException("No arguments passed for the where clause");

			}
			
		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}


		//check if only one argument pair was passed'
		if ( sizeof($arguments) == 2) 
		{
			//get first argument and replace ? with a placeholder
			$arguments[0] = preg_replace("#\?#", "%s", $arguments[0]);

			//quote the argument content
			$arguments[1] = $this->quote($arguments[1]);

			//populate the wheres array
			$this->wheres[] = call_user_func_array("sprintf", $arguments);

			//return this object instance
			return $this;	


		}

		//there are multiple argument supplied
		else
		{
			//get the number of iterations 
			$count = sizeof($arguments) / 2;

			//loop through number of iterations population the wheres array
			for ($i = 0; $i < $count; $i++ ) 
			{ 
				//get the batch of array to work with
				$argumentsPair  = array_splice($arguments, 0, 2);

				//get first argument and replace ? with a placeholder
				$argumentsPair[0] = preg_replace("#\?#", "%s", $argumentsPair[0]);

				//quote the argument content
				$argumentsPair[1] = $this->quote($argumentsPair[1]);
				
				//populate the wheres array
				$this->wheres[] = call_user_func_array("sprintf", $argumentsPair);

			}

			//return this object instance
			return $this;	

		}
		
	}
18646
private function build_where(array $where_array){
        $where_clause = [];
        $counter = 0;
        foreach( $where_array as list($glue, $where) ){
            if( $counter ){
                $where_clause[] = $glue;
            }
            if( is_array($where) ){
                $where_clause[] = $this->build_where($where_array);
            }else{
                $where_clause[] = sprintf('(%s)', $where);
            }
            $counter++;
        }
        return sprintf('(%s)', implode(' ', $where_clause));
    }