Fetch Distinct.

@param $wheres
@return \mixed[]
431680
protected function getFreshDistinct($wheres)
    {
        $column = isset($this->columns[0]) ? $this->columns[0] : '_id';

        // Execute distinct
        if ($wheres) {
            $result = $this->collection->distinct($column, $wheres);
        } else {
            $result = $this->collection->distinct($column);
        }

        return $result;
    }
615495
public function findWhere(array $wheres, array $columns = ['*'])
    {
        return $this->mediator->transform($this->mediator(func_get_args()))->first();
    }
1216753
public function mergeWheres($wheres, $bindings)
    {
        $this->wheres = array_merge((array) $this->wheres, (array) $wheres);

        $this->bindings['where'] = array_values(array_merge($this->bindings['where'], (array) $bindings));
    }
70965
public function findAll(string $from, $wheres = 1, $select = '*', array $options = [])
    {
        $options['select'] = $this->qns($select ?: '*');
        $options['from'] = $this->qn($from);

        list($where, $bindings) = $this->handleWheres($wheres);

        $options['where'] = $where;

        if (!isset($options['limit'])) {
            $options['limit'] = 1000;
        }

        $statement = $this->compileSelect($options);

        if (isset($options['dumpSql'])) {
            return [$statement, $bindings];
        }

        $indexKey = $options['indexKey'] ?? null;

        if ($class = $options['class'] ?? null) {
            return $this->fetchObjects($statement, $bindings, $class, $indexKey);
        }

        $method = 'fetchAssocs';

        if (isset($options['fetchType'])) {
            if ($options['fetchType'] === 'column') {
                // for get columns, indexKey is column number.
                $method = 'fetchColumns';
            } elseif ($options['fetchType'] === 'value') {
                $method = 'fetchValues';
            }
        }

        return $this->$method($statement, $bindings, $indexKey);
    }
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;
		}
1099996
public function getValueWithMultipleWhere($wheres = '', $field = 'id', $fieldOutput = '')
    {
        if (!is_array($fieldOutput)) {
            $fieldOutput = [$fieldOutput];
        }
        $db = $this->db->select($fieldOutput)->from($this->table);
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $key => $value) {
                if (is_array($value['value'])) {
                    $db->whereIn($value['field'], $value['value']);
                } else {
                    $db->where($value['field'], $value['operator'], $value['value']);
                }
            }
        } else {
            $db->where($field, self::OPERATOR_EQUAL_TO, $wheres);
        }
        $result = $db->execute()->fetch();

        $this->debug->debug(__FUNCTION__, 'GET Result => ' . json_encode($result));
        if (isset($result->$fieldOutput)) {
            return $result->$fieldOutput;
        } else {
            return NULL;
        }
    }
740919
public function fetch($where, $order=array(), $skipNum=0, $fetchNum=-1) {
		$obj = $this->getConnection();
        if (empty($where)) {
            return array();
        }
        foreach ($where as $key => $value) {
            $obj->where($key, $value);
        }
		if (empty($order) == false) {
			foreach ($order as $key => $value) {
				$obj->orderBy($key, $value);
			}
		}
		$limits = array();
		if ($fetchNum > 0) {
			if ($skipNum >= 0) {
				array_push($limits, $skipNum);
			}
			array_push($limits, $fetchNum);
		}
		if (empty($limits)) {
		    return $obj->get($this->getDao()->getTableName());
        }

		return $obj->get($this->getDao()->getTableName(), $limits);
	}
351078
protected function prepare($where)
    {
        if (is_string($where)) {
            return str_replace('{@}', $this->alias, $where);
        }

        if (!is_array($where)) {
            return $where;
        }

        $result = [];
        foreach ($where as $column => $value) {
            if (is_string($column) && !is_int($column)) {
                $column = str_replace('{@}', $this->alias, $column);
            }

            $result[$column] = !is_array($value) ? $value : $this->prepare($value);
        }

        return $result;
    }
515807
public function fetchAllAssoc(string $sql, array $params = [], array $types = []): array
    {
        $stmt = $this->conn->executeQuery($sql, $params, $types);

        return $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_UNIQUE);
    }
1128114
public function getWhere()
    {
        $where = $this->where;

        if (! $where) {
            return [];
        }

        foreach ($where['$or'] as &$and) {
            if (isset($and['$and']) && count($and['$and']) === 1) {
                $and = reset($and['$and']);
            }

            if (isset($and['$or']) && count($and['$or']) === 1) {
                $and = reset($and['$or']);
            }
        }

        if (count($where['$or']) === 1) {
            $where = reset($where['$or']);
        }

        return $where;
    }
855845
protected function findByParams($where)
    {
        $model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
        return $model->where($where)->get()->toArray();
    }
930221
public function fetchCount($where = null)
    {
        $select = $this->sql->select();

        if ($where instanceof \Closure) {
            $where($select);
        } elseif ($where !== null) {
            $select->where($where);
        }

        $select->columns(array('Gzfextra_Db_Count' => new Expression('count(1)')));
        $result = $this->sql->prepareStatementForSqlObject($select)->execute()->current();
        return $result['Gzfextra_Db_Count'];
    }
1150597
protected static function query($fields)
    {
        $result = Query::from(static::$table);

        $result = $result->where();

        foreach ($fields as $key => $value) {
            $result = $result->andWhere($key, '=', $value);
        }

        return $result->get();
    }
378353
protected function parseConstraints(array $wheres)
    {
        foreach ($wheres as $column => $value) {
            $this->wheres[] = "{$column} = ?";
            $this->bindings[] = $value;
        }
    }
321474
public function getBy(array $where = [], array $with = [])
    {
        $query = $this->make($with);

        $query = $this->applyWhere($query, $where);

        return $query->get();
    }
923011
public function findMany($ids, $columns = ['*'])
    {
        if (empty($ids)) {
            return [];
        }

        return $this->whereKey($ids)->get($columns);
    }
573004
public function select(): array
	{
		$sql  = $this->query->getPrefix();
		$sql .= $this->setOperations($this->query->getSetOperations());
		$sql .= $this->query->isDistinct() ? 'SELECT DISTINCT ' : 'SELECT ';
		$sql .= $this->columns($this->query->getColumns(), true);
		$sql .= $this->from($this->query->getTable());
		$sql .= $this->joins($this->query->getJoins());
		$sql .= $this->wheres($this->query->getWheres());
		$sql .= $this->groupings($this->query->getGroupings());
		$sql .= $this->havings($this->query->getHavings());
		$sql .= $this->orderings($this->query->getOrderings());
		$sql .= $this->limit($this->query->getLimit());
		$sql .= $this->offset($this->query->getOffset());
		$sql .= $this->lock($this->query->getLock());

		return ['sql' => $sql, 'params' => $this->params];
	}