Doctrine\MongoDB\Query\Builder::selectSlice PHP Method

selectSlice() public method

The $countOrSkip parameter has two very different meanings, depending on whether or not $limit is provided. See the MongoDB documentation for more information.
See also: http://docs.mongodb.org/manual/reference/projection/slice/
public selectSlice ( string $fieldName, integer $countOrSkip, integer $limit = null )
$fieldName string
$countOrSkip integer Count parameter, or skip if limit is specified
$limit integer Limit parameter used in conjunction with skip
    public function selectSlice($fieldName, $countOrSkip, $limit = null)
    {
        $slice = $countOrSkip;
        if ($limit !== null) {
            $slice = [$slice, $limit];
        }
        $this->query['select'][$fieldName] = ['$slice' => $slice];
        return $this;
    }