Gets the distinct values of a column
@param string $column
@param array $criteria Array with values \DBScribe\Row or array of [column => value]
@return ArrayCollection
499293
public function distinct($column, array $criteria = array(),
            $return = Table::RETURN_MODEL) {
        $this->current = self::OP_SELECT;
        $this->setExpectedResult($return, true);
        $this->targetColumns($column);
        $this->query = 'SELECT DISTINCT `' . $this->name . '`.`' . Util::camelTo_($column) . '` as ' . Util::_toCamel($column) . ' FROM `' . $this->name . '` ' . $this->joinQuery;
        $this->where($criteria);

        return $this->execute();
    }
884471
public function max($column, bool $distinct = false)
    {
        parent::max($column, $distinct);
        return $this->getColumnResult();
    }
1175364
public function max($column, bool $distinct = false): self
    {
        return $this->addFunction('aggregateFunction', 'MAX', $column, ['distinct' => $distinct]);
    }
103136
public function getMultiCount($collection, $column, array $values, array $extra = [])
    {
        $query = $this->table($collection)->whereIn($column, $values);

        return $this->addConditions($query, $extra)->distinct()->count($column);
    }
1282234
public function distinct(array $c){
		$columns = [];
		foreach($c as $s){
			array_push($columns, \Dorsataio\Squibble\Resource\Extract::fromColumn($s));
		}
		$this->_distinctClause = $this->getDistinctStatement($columns);
		return $this;
	}
138350
public function lists($column, $key = null)
	{
		$columns = $this->getListSelect($column, $key);

		$results = new Collection($this->get($columns));

		return $results->lists($columns[0], array_get($columns, 1));
	}
697668
public function getDatabaseSeriesData(Criteria $criteria)
    {
        $dbData = [];

        $res = $this->database->query("SELECT {$criteria->getValueField()} AS value,
calendar.week AS week,
calendar.month AS month,
calendar.year AS year,
{$this->getSeries($criteria->getSeries())}
{$criteria->getTableName()}.id
FROM {$criteria->getTableName()}
INNER JOIN calendar ON date({$criteria->getTableName()}.{$criteria->getTimeField()}) = calendar.date
    AND calendar.date >= '{$criteria->getStartDate()}'
	AND calendar.date <= '{$criteria->getEndDate()}'
    {$criteria->getJoin()}
WHERE
    {$criteria->getTableName()}.{$criteria->getTimeField()} >= '{$criteria->getStartDate()}' 
AND {$criteria->getTableName()}.{$criteria->getTimeField()} <= '{$criteria->getEndDate()}'
	{$criteria->getWhere()}
GROUP BY calendar.year,calendar.month,calendar.week" . $this->getGroupBy($criteria->getGroupBy()) . '
		');

        foreach ($res as $row) {
            $value = 0;
            if ($row->id != null) {
                $value = $row['value'];
            }
            $date = new \DateTime();
            $date->setISODate($row->year, $row->week);
            if (isset($row->name)) {
                $dbData[$row->name][$date->format('Y-m-d')] = $value;
            } else {
                $dbData[' '][$date->format('Y-m-d')] = $value;
            }
        }
        return $dbData;
    }
554686
public function sum($column, bool $distinct = false): self
    {
        return $this->addFunction('aggregateFunction', 'SUM', $column, ['distinct' => $distinct]);
    }
790666
public function findRandomOneBy(array $criteria)
    {
        $queryBuilder = $this->getQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);

        return $queryBuilder
            ->addSelect('RAND() as HIDDEN rand')
            ->orderBy('rand')
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
1029396
final public function distinct($column)
    {
        if (!is_array($column)) {
            $column = explode(',', $column);
        }
        $column = array_map([$this, 'formatColumn'], $column);

        $this->_sql['distinct'] = array_merge($this->_sql['distinct'], $column);
        return $this;
    }
71128
public function pluck($column)
    {
        $columns = func_get_args();
        $argv_count = func_num_args();
        
        $collection = $this->take();
        $values = [];
        
        if ($collection->any()) {
            if ($argv_count == 1) {
                foreach ($collection as $model)
                    $values[] = $model->$column;
            } else {
                foreach ($collection as $model) {
                    $row_values = [];
                    foreach ($columns as $column) {
                        $row_values[] = $model->$column;
                    }
                    $values[] = $row_values;
                }
            }
        }
        
        return $values;
    }
365879
public function matching(Criteria $criteria)
    {
        $allEntities = $this->wrapped->findAll();
        $collection = new ArrayCollection($allEntities);

        return $collection->matching($criteria);
    }
66647
public function unique($criteria = null, array $values = array())
    {
        if (!$this->_properties['primary_key'] || (!$values && !$criteria))
            throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);

        $that = clone $this;
        $values ? $that->find($criteria, $values) : $that->findByPK($criteria);

        return ($that->dry() || $this->pkCompare($that->pkValue()));
    }
735841
public function getCol(string $query, array $criteria = []): array {
		try {
			$results = $this->dbConn->fetchCol($query, $criteria);
			return is_array($results) ? $results : [];
		} catch (\PDOException $pdoException) {
			throw $this->prepareDatabaseException($pdoException, $query, $criteria);
		}
	}
399573
public function get($columns = ['*']): Collection
    {
        // First we'll add the proper select columns onto the query so it is run with
        // the proper columns. Then, we will get the results and hydrate out pivot
        // entities with the result of those columns as a separate model relation.
        $select = $this->getSelectColumns($columns);

        $entities = $this->query->addSelect($select)->getEntities();

        // If we actually found entities we will also eager load any relationships that
        // have been specified as needing to be eager loaded. This will solve the
        // n + 1 query problem for the developer and also increase performance.
        if (count($entities) > 0) {
            $entities = $this->query->eagerLoadRelations($entities);
        }

        return $this->relatedMap->newCollection($entities);
    }
334692
public function count($column = '*', bool $distinct = false): self
    {
        if (!is_array($column)) {
            $column = [$column];
        }
        $distinct = $distinct || (count($column) > 1);
        return $this->addFunction('aggregateFunction', 'COUNT', $column, ['distinct' => $distinct]);
    }
230733
public function sortBy($criteria)
    {
        $criteria = $this->factoryCallableCriteria($criteria);
        $sorted   = $this->create();
        $groups   = $this->groupBy($criteria);

        $criterias = $this->map(function ($element, $key) use ($criteria) {
            return $criteria($element, $key);
        })->toArray();

        sort($criterias);
        $criterias = array_unique($criterias);

        foreach ($criterias as $key) {
            foreach ($groups[$key] as $element) {
                $sorted[] = $element;
            }
        }

        return $sorted;
    }