Adds a distinct clause to a select query statement

@param boolean $boolean
@return ActiveRecord
771155
final public function distinct($boolean = TRUE)
    {
        $this->arrayDistinct = (is_bool($boolean)) ? $boolean : TRUE;
        return $this;
    }
1364213
public function select($select, $distinct = FALSE){
        if($distinct){
            $this->select= 'DISTINCT ';
        }else{
            $this->select= '';
        }
        $this->select .= $select;
    }
1356495
private function getRuleSelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT r.*', 'rd.*')
            ->from('ngbm_rule', 'r')
            ->innerJoin(
                'r',
                'ngbm_rule_data',
                'rd',
                $query->expr()->eq('rd.rule_id', 'r.id')
            );

        return $query;
    }
459492
protected function createCountQuery(array $fields = [], array $criteria = [], $distinct = true)
	{
		if ($this->objectManager instanceof \Doctrine\ORM\EntityManager) {
			/** @var \Doctrine\ORM\QueryBuilder $builder */
			$builder = $this->objectManager->createQueryBuilder();
			
			if (empty($fields)) {
				/** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata */
				$classMetadata = $this->objectManager->getClassMetadata($this->className);
				$identifier = $classMetadata->getIdentifierFieldNames()[0];
			} else {
				$identifier = $fields[0]; // Replace with $identifier = implode(', p.', $fields);
			}
			
			$builder->select($distinct ? $builder->expr()->countDistinct('p.' . $identifier) : $builder->expr()->count('p.' . $identifier))
					->from($this->className, 'p');
		} elseif ($this->objectManager instanceof \Doctrine\ODM\MongoDB\DocumentManager) {
			/** @var \Doctrine\ODM\MongoDB\Query\Builder $builder */
			$builder = $this->objectManager->createQueryBuilder($this->className);
			
			if (false === empty($fields) && true === $distinct) {
				$builder->distinct($fields[0]);
			}
			
			$builder->count();
		} else {
			throw new ObjectManagerNotSupportedException(sprintf('Doctrine object manager class "%s" is not supported.', get_class($this->objectManager)));
		}
		
		$this->qbHandler->applyExprFromArray($builder, 'p', $criteria);
		
		return $builder->getQuery();
	}
1280148
function Select($distinct, SelectList $selectList, Source $source, Condition $condition = null, OrderList $orderList = null, GroupList $groupList = null, $offset = 0, $count = 0)
    {
        return parent::CreateSelect($distinct, $selectList, $source, $condition, $orderList, $groupList, $offset, $count); 
    }
1328982
public function min($column, bool $distinct = false): self
    {
        return $this->addFunction('aggregateFunction', 'MIN', $column, ['distinct' => $distinct]);
    }
614706
public function havingRaw($sql, array $bindings = array(), $boolean = 'and')
    {
        $type = 'raw';

        $this->havings[] = compact('type', 'sql', 'boolean');

        $this->addBinding($bindings, 'having');

        return $this;
    }
505767
protected function createNestedWhere($whereSlice, $boolean = 'and')
    {
        $whereGroup = $this->getQuery()->forNestedWhere();

        $whereGroup->wheres = $whereSlice;

        return ['type' => 'Nested', 'query' => $whereGroup, 'boolean' => $boolean];
    }
952615
public function where($column, $operator = null, $value = null, $boolean = 'and') {
        // If the column is an array, we will assume it is an array of key-value pairs
        // and can add them each as a where clause. We will maintain the boolean we
        // received when the method was called and pass it into the nested where.
        if (is_array($column)) {
            return $this->whereNested(function ($query) use ($column) {
                        foreach ($column as $key => $value) {
                            $query->where($key, '=', $value);
                        }
                    }, $boolean);
        }

        // Here we will make some assumptions about the operator. If only 2 values are
        // passed to the method, we will assume that the operator is an equals sign
        // and keep going. Otherwise, we'll require the operator to be passed in.
        if (func_num_args() == 2) {
            list($value, $operator) = [$operator, '='];
        } elseif ($this->invalidOperatorAndValue($operator, $value)) {
            throw new InvalidArgumentException('Illegal operator and value combination.');
        }

        // If the columns is actually a Closure instance, we will assume the developer
        // wants to begin a nested where statement which is wrapped in parenthesis.
        // We'll add that Closure to the query then return back out immediately.
        if ($column instanceof Closure) {
            return $this->whereNested($column, $boolean);
        }

        // If the given operator is not found in the list of valid operators we will
        // assume that the developer is just short-cutting the '=' operators and
        // we will set the operators to '=' and set the values appropriately.
        if (!in_array(strtolower($operator), $this->operators, true)) {
            list($value, $operator) = [$operator, '='];
        }

        // If the value is a Closure, it means the developer is performing an entire
        // sub-select within the query and we will need to compile the sub-select
        // within the where clause to get the appropriate query record results.
        if ($value instanceof Closure) {
            return $this->whereSub($column, $operator, $value, $boolean);
        }

        // If the value is "null", we will just assume the developer wants to add a
        // where null clause to the query. So, we will allow a short-cut here to
        // that method for convenience so the developer doesn't have to check.
        if (is_null($value)) {
            return $this->whereNull($column, $boolean, $operator != '=');
        }

        // Now that we are working with just a simple query we can put the elements
        // in our array and add the query binding to our array of bindings that
        // will be bound to each SQL statements when it is finally executed.
        $type = 'Basic';

        $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');

        if (!$value instanceof Expression) {
            $this->addBinding($value, 'where');
        }

        return $this;
    }
869923
public function union($queries, $distinct = false)
    {
        if ($this->_db === null) {
            foreach ($queries as $query) {
                if ($query instanceof self) {
                    $this->_db = $query->_db;
                    break;
                }
            }
        }
        $this->_union = ['type' => 'UNION ' . ($distinct ? 'DISTINCT' : 'ALL'), 'queries' => $queries];

        return $this;
    }
69170
public function where($column, $operator = '=', $value = null, $boolean = 'and', array $columns = ['*'])
    {
        return $this->repository->makeQuery()->where($column, $operator, $value, $boolean, $columns)->get($columns);
    }
764901
public function distinct($column = false)
    {
        $this->distinct = true;

        if ($column) {
            $this->columns = [$column];
        }

        return $this;
    }
56481
protected function whereCountQuery( QueryBuilder $query, $operator = '>=', $count = 1, $boolean = 'and' )
	{
		if ( is_numeric( $count ) )
		{
			$count = new Expression( $count );
		}

		$this->query->addBinding( $query->getBindings(), 'where' );

		return $this->where( new Expression( '(' . $query->toSql() . ')' ), $operator, $count, $boolean );
	}
920024
public function whereNull($column, $boolean = 'and', $not = false)
    {
        $type = $not ? 'NotNull' : 'Null';

        if ($column == 'id') $column = 'id('. $this->modelAsNode() .')';

        $binding = $this->prepareBindingColumn($column);

        $this->wheres[] = compact('type', 'column', 'boolean', 'binding');

        return $this;
    }
1135263
public function whereBetween($column, array $values, $boolean = 'and', $not = false)
	{
		$type = 'between';

		$this->wheres[] = compact('column', 'type', 'boolean', 'not');

		$this->bindings = array_merge($this->bindings, $values);

		return $this;
	}
381535
public function use_fallback($boolean = NULL)
	{
		if ($boolean === NULL)
		{
			return $this->_use_fallback;
		}
		$this->_use_fallback = $boolean;
		return $this;
	}
339350
protected function compileQuerySearch($query, $column, $keyword, $boolean = 'or')
    {
        $column = $this->addTablePrefix($query, $column);
        $column = $this->castColumn($column);
        $sql    = $column . ' LIKE ?';

        if ($this->config->isCaseInsensitive()) {
            $sql = 'LOWER(' . $column . ') LIKE ?';
        }

        $query->{$boolean . 'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]);
    }