src/AbstractProcessor.php
protected function shouldLtrim(Query $query, $rows)
    {
        $first = $this->offset($rows, 0);

        $selectOrUnionAll = $query->selectOrUnionAll();

        // If we are not using UNION ALL or the elements are empty...
        if (!$selectOrUnionAll instanceof UnionAll || !$first) {
            return false;
        }

        foreach ($selectOrUnionAll->supportQuery()->orders() as $order) {

            // Retrieve values
            $field = $this->field($first, $order->column());
            $cursor = $query->cursor()->get($order->column());

            // Compare the first row and the cursor
            if (!$diff = $this->compareField($field, $cursor)) {
                continue;
            }

            //
            // Drop the first row if ...
            //
            //
            //  - the support query is descending  &&  $field < $cursor
            //
            //               -------------------->  Main query, ascending
            //           [4, <5>, 6, 7, 8, 9, 10]
            //         <-----                       Support query, descending
            //
            //                               ---->  Support query, descending
            //           [10, 9, 8, 7, 6, <5>, 4]
            //         <---------------------       Main query, ascending
            //
            //
            //  - the support query is ascending   &&  $field > $cursor
            //
            //                              ----->  Support query, ascending
            //           [4, 5, 6, 7, 8, <9>, 10]
            //         <--------------------        Main query, descending
            //
            //               -------------------->  Main query, descending
            //           [10, <9>, 8, 7, 6, 5, 4]
            //         <----                        Support query, ascending
            //
            return $diff === ($order->descending() ? -1 : 1);
        }

        // If the first row and the cursor are identical, we should drop the first row only if exclusive.
        return $query->exclusive();
    }
protected function shouldLtrim(Query $query, $rows)
    {
        $first = $this->offset($rows, 0);

        $selectOrUnionAll = $query->selectOrUnionAll();

        // If we are not using UNION ALL or the elements are empty...
        if (!$selectOrUnionAll instanceof UnionAll || !$first) {
            return false;
        }

        foreach ($selectOrUnionAll->supportQuery()->orders() as $order) {

            // Retrieve values
            $field = $this->field($first, $order->column());
            $cursor = $query->cursor()->get($order->column());

            // Compare the first row and the cursor
            if (!$diff = $this->compareField($field, $cursor)) {
                continue;
            }

            //
            // Drop the first row if ...
            //
            //
            //  - the support query is descending  &&  $field < $cursor
            //
            //               -------------------->  Main query, ascending
            //           [4, <5>, 6, 7, 8, 9, 10]
            //         <-----                       Support query, descending
            //
            //                               ---->  Support query, descending
            //           [10, 9, 8, 7, 6, <5>, 4]
            //         <---------------------       Main query, ascending
            //
            //
            //  - the support query is ascending   &&  $field > $cursor
            //
            //                              ----->  Support query, ascending
            //           [4, 5, 6, 7, 8, <9>, 10]
            //         <--------------------        Main query, descending
            //
            //               -------------------->  Main query, descending
            //           [10, <9>, 8, 7, 6, 5, 4]
            //         <----                        Support query, ascending
            //
            return $diff === ($order->descending() ? -1 : 1);
        }

        // If the first row and the cursor are identical, we should drop the first row only if exclusive.
        return $query->exclusive();
    }
protected function shouldLtrim ( Query $ query , $ rows ) { $ first = $ this -> offset ( $ rows , 0 ) ; $ selectOrUnionAll = $ query -> selectOrUnionAll ( ) ; // If we are not using UNION ALL or the elements are empty... if ( ! $ selectOrUnionAll instanceof UnionAll || ! $ first ) { return false ; } foreach ( $ selectOrUnionAll -> supportQuery ( ) -> orders ( ) as $ order ) { // Retrieve values $ field = $ this -> field ( $ first , $ order -> column ( ) ) ; $ cursor = $ query -> cursor ( ) -> get ( $ order -> column ( ) ) ; // Compare the first row and the cursor if ( ! $ diff = $ this -> compareField ( $ field , $ cursor ) ) { continue ; } // // Drop the first row if ... // // //  - the support query is descending  &&  $field < $cursor // //               -------------------->  Main query, ascending //           [4, <5>, 6, 7, 8, 9, 10] //         <-----                       Support query, descending // //                               ---->  Support query, descending //           [10, 9, 8, 7, 6, <5>, 4] //         <---------------------       Main query, ascending // // //  - the support query is ascending   &&  $field > $cursor // //                              ----->  Support query, ascending //           [4, 5, 6, 7, 8, <9>, 10] //         <--------------------        Main query, descending // //               -------------------->  Main query, descending //           [10, <9>, 8, 7, 6, 5, 4] //         <----                        Support query, ascending // return $ diff === ( $ order -> descending ( ) ? - 1 : 1 ) ; } // If the first row and the cursor are identical, we should drop the first row only if exclusive. return $ query -> exclusive ( ) ; }
Determine if the first row should be dropped.

@param  Query $query
@param  mixed $rows
@return bool
Determine if the first row should be dropped .