{"record":{"id":"f1f1db7144c99ccf","repo":"phalcon/cphalcon","slug":"at-least-one-model-is-required-to-build-the-query","errorCode":null,"errorMessage":"At least one model is required to build the query","messagePattern":"At least one model is required to build the query","errorType":"exception","errorClass":"ModelRequired","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query/Builder.zep","lineNumber":714,"sourceCode":"        var container, models, conditions, model, metaData, modelInstance,\n            primaryKeys, firstPrimaryKey, columnMap, modelAlias,\n            attributeField, phql, column, columns, selectedColumns,\n            selectedColumn, selectedModel, selectedModels, columnAlias,\n            modelColumnAlias, joins, join, joinModel, joinConditions,\n            joinAlias, joinType, group, groupItems, groupItem, having, order,\n            orderItems, orderItem, limit, number, offset, forUpdate, distinct;\n        bool noPrimary;\n\n        let container = this->container;\n        if typeof container != \"object\" {\n            let container = Di::getDefault(),\n                this->container = container;\n        }\n\n        let models = this->models;\n        if typeof models == \"array\" {\n            if unlikely empty models {\n                throw new ModelRequired();\n            }\n        } else {\n            if unlikely !models {\n                throw new ModelRequired();\n            }\n        }\n\n        let conditions = this->conditions;\n\n        if is_numeric(conditions) {\n            /**\n             * If the conditions is a single numeric field. We internally create\n             * a condition using the related primary key\n             */\n            if typeof models == \"array\" {\n                if unlikely count(models) > 1 {\n                    throw new BuilderConditionInvalid();\n                }","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query/Builder.zep#L696-L732","documentation":"Error \"At least one model is required to build the query\" thrown in phalcon/cphalcon.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query/Builder.zep:714 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}