phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\IndexNotInCursor

The index does not exist in the cursor

Error message

The index does not exist in the cursor

What it means

Guard in Resultset::offsetGet (ArrayAccess): the requested offset is >= the resultset count, so the cursor has no row at that index. The input at fault is an out-of-range index passed via $resultset[$i] or offsetGet().

Solutions

  1. Check $resultset->offsetExists($i) or count($resultset) before accessing an index.
  2. Use foreach or valid()/seek() iteration instead of random access with unknown indexes.
  3. Clamp or validate user-supplied page/offset values before indexing.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Resultset.zep:601 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/2499590867befcbc. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Resultset.zep:601

            this->pointer + 1
        );
    }

    /**
     * Checks whether offset exists in the resultset
     */
    public function offsetExists(var index) -> bool
    {
        return index < this->count();
    }

    /**
     * Gets row in a specific position of the resultset
     */
    public function offsetGet(mixed index) -> mixed
    {
        if unlikely index >= this->count() {
            throw new IndexNotInCursor();
        }

        /**
         * Move the cursor to the specific position
         */
        this->seek(index);

        return this->{"current"}();
    }

    /**
     * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
     *
     * @param int offset
     * @param \Phalcon\Mvc\ModelInterface value
     */
    public function offsetSet(var offset, var value) -> void
    {

View on GitHub (pinned to b7419de9cd)