phalcon/cphalcon · error · Phalcon\Paginator\Exceptions\InvalidBuilderInstance
Parameter 'builder' must be an instance of…
Error message
Parameter 'builder' must be an instance of Phalcon\Mvc\Model\Query\Builder
What it means
Constructor guard: the 'builder' entry in the config array was present but is not an instance of Phalcon\Mvc\Model\Query\Builder (e.g. a plain PHQL string, an array, or an object of the wrong class). The cursor paginator can only paginate a query produced by that Builder class.
Solutions
- Pass a fully constructed Phalcon\Mvc\Model\Query\Builder as config['builder'], e.g. new Builder() with from()/columns()/where() configured
- Verify no other Builder class (e.g. Phalcon\Storage or a custom builder) is accidentally imported in the calling file
- Check that the builder was not set to null or overwritten before being passed in the config array
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Paginator/Adapter/QueryBuilderCursor.zep:106 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/f9d96e03a483bdab.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Paginator/Adapter/QueryBuilderCursor.zep:106
* 'builder' => null,
* 'cursorColumn' => 'id',
* 'cursor' => null
* ]
*/
public function __construct(array config)
{
var builder, cursorColumn, cursor;
if unlikely !isset config["limit"] {
throw new MissingRequiredParameter("limit");
}
if unlikely !fetch builder, config["builder"] {
throw new MissingRequiredParameter("builder");
}
if unlikely !(builder instanceof Builder) {
throw new InvalidBuilderInstance();
}
if unlikely !fetch cursorColumn, config["cursorColumn"] {
throw new MissingRequiredParameter("cursorColumn");
}
if unlikely typeof cursorColumn != "string" || empty cursorColumn {
throw new InvalidCursorColumn();
}
let this->cursorColumn = cursorColumn;
if fetch cursor, config["cursor"] {
let this->cursor = cursor;
}
parent::__construct(config);
View on GitHub (pinned to b7419de9cd)