phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\MixedDatabaseSystems
Cannot use models of different database systems in the same…
Error message
Cannot use models of different database systems in the same query
What it means
In executeSelect(), connections are collected per DBMS type; when a query touches models backed by two different database systems, MixedDatabaseSystems is thrown because PHQL cannot join across engines. The faulty input is a PHQL query combining models with different adapters (e.g. MySQL + PostgreSQL).
Solutions
- Query each model separately and combine results in application code
- Move both models onto the same database system/connection
- Split cross-database relations into separate service calls
Defensive patterns
Strategy: validation
Prevention
- Keep related models on the same DBMS
- Detect mixed connections in integration tests for complex queries
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:1135 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/fd5dbdf1623fe634.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:1135
intermediate,
bindParams,
bindTypes
);
} else {
let connection = this->getReadConnection(
model,
intermediate,
bindParams,
bindTypes
);
}
if typeof connection == "object" {
// More than one type of connection is not allowed
let connectionTypes[connection->getType()] = true;
if unlikely count(connectionTypes) == 2 {
throw new MixedDatabaseSystems();
}
}
}
let columns = intermediate["columns"];
let haveObjects = false,
haveScalars = false,
isComplex = false;
// Check if the resultset have objects and how many of them have
let numberObjects = 0;
let columns1 = columns;
for column in columns {
if unlikely typeof column != "array" {
throw new InvalidColumnDefinition();
}View on GitHub (pinned to b7419de9cd)