phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\PrimaryKeyRequired
A primary key must be defined in the model in order to perfo
Error message
A primary key must be defined in the model in order to perform the operation in '{className}' What it means
Error "A primary key must be defined in the model in order to perform the operation in '{className}'" thrown in phalcon/cphalcon.
Source
Thrown at phalcon/Mvc/Model.zep:1546
let values = [],
bindTypes = [],
conditions = [];
let primaryKeys = metaData->getPrimaryKeyAttributes(this),
bindDataTypes = metaData->getBindTypes(this);
if Settings::get("orm.column_renaming") {
let columnMap = metaData->getColumnMap(this);
} else {
let columnMap = null;
}
/**
* We can't create dynamic SQL without a primary key
*/
if unlikely empty primaryKeys {
throw new PrimaryKeyRequired(get_class(this));
}
/**
* Create a condition from the primary keys
*/
for primaryKey in primaryKeys {
/**
* Every column part of the primary key must be in the bind data
* types
*/
if unlikely !fetch bindType, bindDataTypes[primaryKey] {
throw new BindTypeNotDefined(primaryKey, get_class(this));
}
/**
* Take the column values based on the column map if any
*/
if typeof columnMap == "array" {View on GitHub (pinned to b7419de9cd)
When it happens
Trigger: Thrown at phalcon/Mvc/Model.zep:1546 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/c6f5d81f4971b276.
Report an issue: GitHub.