phalcon/cphalcon · error · ReadConnectionMissing
selectReadConnection did not return a connection
Error message
selectReadConnection did not return a connection
What it means
Thrown in Query::getReadConnection when the model implements selectReadConnection() but that callback returned a non-object instead of a connection adapter, so the query has no usable read connection. The input at fault is the return value of the custom selectReadConnection method.
Solutions
- Make selectReadConnection() return a valid \Phalcon\Db\AdapterInterface instance for all code paths.
- Check the custom connection-selection logic for branches that return null.
- Add unit tests covering the connection selector with the same intermediate/bind arguments.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3344 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/fe9cf27c23deadc8.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:3344
{
var connection = null, transaction;
let transaction = this->transaction;
if typeof transaction == "object" && transaction instanceof TransactionInterface {
return transaction->getConnection();
}
if method_exists(model, "selectReadConnection") {
// use selectReadConnection() if implemented in extended Model class
let connection = model->selectReadConnection(
intermediate,
bindParams,
bindTypes
);
if unlikely typeof connection != "object" {
throw new ReadConnectionMissing();
}
return connection;
}
return model->getReadConnection();
}
/**
* Query the records on which the UPDATE/DELETE operation will be done
*
* @return ResultsetInterface
*/
final protected function getRelatedRecords(<ModelInterface> model, array intermediate, array bindParams, array bindTypes) -> <ResultsetInterface>
{
var selectIr, joinConditions, whereConditions, limitConditions, query;
/**View on GitHub (pinned to b7419de9cd)