phalcon/cphalcon · error · DuplicateAlias
Alias ' ' is used more than once, when preparing
Error message
Alias '{name}' is used more than once, when preparing: {phql} What it means
Thrown in Query::prepareSelect while processing selected models: a FROM/JOIN model alias appears more than once in this->sqlAliases, so two models would resolve under the same alias. The input at fault is the duplicated alias name in the PHQL.
Solutions
- Use a distinct alias for each model occurrence, e.g. FROM ModelA AS a JOIN ModelB AS b.
- Fix programmatic PHQL builders that append the same alias twice.
- Qualify columns with the corrected unique aliases afterwards.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:4013 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/9d94153c8f8cca49.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:4013
// Define a complete schema/source
let schema = model->getSchema(),
source = model->getSource();
// Obtain the real source including the schema
if schema {
let completeSource = [source, schema];
} else {
let completeSource = source;
}
/**
* If an alias is defined for a model then the model cannot be
* referenced in the column list
*/
if fetch alias, selectedModel["alias"] {
// Check if the alias was used before
if unlikely isset sqlAliases[alias] {
throw new DuplicateAlias(alias, this->phql);
}
let sqlAliases[alias] = alias,
sqlAliasesModels[alias] = modelName,
sqlModelsAliases[modelName] = alias,
sqlAliasesModelsInstances[alias] = model;
/**
* Append or convert complete source to an array
*/
if typeof completeSource == "array" {
let completeSource[] = alias;
} else {
let completeSource = [source, null, alias];
}
let models[modelName] = alias;
} else {View on GitHub (pinned to b7419de9cd)