Get all keys of a given value.

@param mixed $value : the value whose keys to get
@param int $limit : the maximum amount of keys to get; 0 - no limit, negative value - get the last N keys
@return array an array containing all keys that were found
510271
public function getKeys($value, int $limit = 0): array
	{
		$predicate = function ($v, $k) use ($value)
		{
			return ($v === $value);
		};
		
		return $this->find($predicate, true, $limit);
	}
401059
public function validate($value) : Result
    {
        return array_reduce(
            $this->restrictions,
            function ($result, $restriction) use ($value) : Result {
                if ($result->isFatal()) {
                    return $result;
                }

                return $result->concat($restriction($value));
            },
            Result::success()
        );
    }
1059461
public function loadAll($offset = 0, $limit = -1)
    {
        return $this->mapper->extractUrlWildcardsFromRows(
            $this->gateway->loadUrlWildcardsData($offset, $limit)
        );
    }
479219
public static function limit($limit) {
        //1. limit(10);
        if ( is_numeric($limit) ) {
            return array(0, $limit);

            //2. limit("10, 50")
        } else if ( is_string( $limit ) ) {
            return explode(',', $limit);
        }
        return $limit;
    }
682954
public function getByValue(string $key, $value)
    {
        return array_filter($this->items, function ($val) use ($key, $value) {
            return $val[$this->normalizeKey($key)] === $value;
        });
    }
1083424
public function findAll($limit = 0, $offset = 0)
    {
        $limit = $this->getLimit($limit, $offset);
        $query = 'SELECT ' . $this->getFields(", ") . '
                  FROM ' . $this->tableName . '
                  ' . $limit . ' ;';
        $statement = $this->database->prepare($query);
        $statement->execute();
        return $this->buildAll($statement->fetchAll());
    }
689061
public function getByGroupId($value, $limit = 1000, $useConnection = 'read')
    {
        if (is_null($value)) {
            throw new \Exception('Value passed to ' . __FUNCTION__ . ' cannot be null.');
        }

        $query = 'SELECT * FROM `project` WHERE `group_id` = :group_id ORDER BY title LIMIT :limit';
        $stmt = Database::getConnection($useConnection)->prepare($query);
        $stmt->bindValue(':group_id', $value);
        $stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

        if ($stmt->execute()) {
            $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $map = function ($item) {
                return new Project($item);
            };
            $rtn = array_map($map, $res);

            $count = count($rtn);

            return array('items' => $rtn, 'count' => $count);
        } else {
            return array('items' => array(), 'count' => 0);
        }
    }
880445
public function getWhere($column, $value, $limit = null)
	{
        $related = $this->modelClassInstance->where($column, '=', $value);

        return $related;
    }
1268599
public function getItems($offset, $limit)
    {
        $this->cursor->skip($offset);
        $this->cursor->limit($limit);

        return iterator_to_array($this->cursor);
    }
396208
public function get($limit = null, $offset = null)
    {
        if (isset($limit)) {
            $this->limit($limit, $offset);
        }

        if (false !== ($result = $this->conn->query($this->builderCache))) {
            $result->setTotalRows($this->countAllResults(true));
        }

        $this->builderCache->reset();

        return $result;
    }
13084
public function limit($start, $limit = null) {
        if ($limit === null) {
            $limit = intval($start);
            $start = 0;
        } else {
            $start = intval($start);
            $limit = intval($limit);
        }
        if ($start < 0) {
            $start = 0;
        }
        if (!$limit) {
            $limit = 1;
        }
        $this->limit = [$start, $limit];
        if ($this->statement) {
            $this->updateWhereData([':limit_0' => $start, ':limit_1' => $limit]);
        }

        return $this;
    }
281618
public static function isAfter($value, $limit, $inclusive = false)
    {
        $value = self::convertToDateTime($value);
        $limit = self::convertToDateTime($limit);

        if (false === $inclusive) {
            return \strtotime($value->format('Y-m-d H:i:s')) > \strtotime($limit->format('Y-m-d H:i:s'));
        }

        return \strtotime($value->format('Y-m-d H:i:s')) >= \strtotime($limit->format('Y-m-d H:i:s'));
    }
1075189
public function fetchAll($limit = null, $offset = null){
		$limit = $limit === null ? -1 : (int) $limit;
		if($offset !== null)
			$this->seek((int) $offset);

		$row = $this->fetch();
		if(!$row)
			return array();

		$rows = array();
		do{
			if($limit === 0)
				break;
			$rows[] = $row;
			$limit--;
		} while($row = $this->fetch());

		return $rows;
	}
1239051
public function getResult($limit = 0, $offset = 0)
    {
        $this->count();
        $this->queryBuilder->setFirstResult($offset)->setMaxResults($limit);

        if ($limit > 0) {
            $pathOrderBy = $this->getSqlPart($this->queryBuilder, 'orderBy');
            $this->resetSqlParts($this->queryBuilder, ['orderBy']);
            $qb = $this->cloneQb($this->queryBuilder);
            $qb->select(sprintf('%s', $this->aliasDotPrimary()))
                ->setFirstResult(null)
                ->setMaxResults(null);

            /** @var OrderBy $part */
            foreach ($pathOrderBy as $part) {
                foreach ($part->getParts() as $order) {
                    $out = [];
                    preg_match('/(.*[^\s])?\s+(asc|desc)/i', $order, $out);
                    $property = $out[1];
                    $direction = $out[2];
                    $alias = ($key = array_search($property, $this->aliasMapping)) ?: $property;
                    if ($this->isAggFunc($property)) {
                        $qb->addSelect($property.' AS '.$alias);
                        $qb->addOrderBy($alias, $direction);
                        $this->queryBuilder->addOrderBy($alias, $direction);
                    } else {
                        $qb->addOrderBy($property, $direction);
                        $this->queryBuilder->addOrderBy($property, $direction);
                    }
                }
            }

            $query = $qb->getQuery();

            foreach ($this->hints as $name => $hint) {
                $query->setHint($name, $hint);
            }

            $params = $types = [];
            /** @var Parameter $parameter */
            foreach ($query->getParameters() as $key => $parameter) {
                $params[$key] = $parameter->getValue();
                $types[$key] = $parameter->getType();
            }

            /** @var \PDOStatement $stmt */
            $stmt = $this->queryBuilder->getEntityManager()->getConnection()->executeQuery(
                $query->getSQL(),
                $params,
                $types
            );

            $ids = $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
            $ids = array_values(array_unique($ids));

            if (!$ids) {
                return [];
            }
            $ids = array_slice($ids, $offset, $limit);
            $this->queryBuilder
                ->setFirstResult(null)
                ->setMaxResults(null)
                ->where(sprintf("%s IN (:_sps_ids_)", $this->aliasDotPrimary()))
                ->setParameters(['_sps_ids_' => $ids]);
        }
        $query = $this->queryBuilder->getQuery();
        foreach ($this->hints as $name => $hint) {
            $query->setHint($name, $hint);
        }
        $this->result = $query->getResult();
        if (!$this->totalResultCount) {
            $this->totalResultCount = count($this->result);
        }

        return $this->result;
    }
321472
public function fetchPairs($key, $value = NULL) {
		$return = array();
		foreach ($this as $row) {
			$return[$row->$key] = $value ? $row->$value : $row->$key;
		}
		return $return;
	}
150049
public function lastIndexOf($value) {
        $array = [];
        foreach ($this->array as $key => $val) {
            if (null === $val) {
                continue;
            }
            if (Comparator::equals($val, $value)) {
                $array[] = $key;
            }
        }
        return \count($array) === 0 ? null : $array;
    }
282816
public function getKey($value) {
		foreach ($this->collection as $k => $v) {
			if ($v === $value) {
				return $k;
			}
		}
		
		return null;
	}