{"record":{"id":"a7e3c60ac6903c0e","repo":"phalcon/cphalcon","slug":"the-using-parameter-should-be-an-array","errorCode":null,"errorMessage":"The 'using' parameter should be an array","messagePattern":"The 'using' parameter should be an array","errorType":"exception","errorClass":"Phalcon\\Tag\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Tag/Select.zep","lineNumber":117,"sourceCode":"            }\n\n            unset params[\"useEmpty\"];\n        }\n\n        if !fetch options, params[1] {\n            let options = data;\n        }\n\n        if typeof options == \"object\" {\n            /**\n             * The options is a resultset\n             */\n            if unlikely !fetch using, params[\"using\"] {\n                throw new Exception(\"The 'using' parameter is required\");\n            }\n\n            if unlikely (typeof using != \"array\" && typeof using != \"object\") {\n                throw new Exception(\n                    \"The 'using' parameter should be an array\"\n                );\n            }\n        }\n\n        unset params[\"using\"];\n\n        let code = BaseTag::renderAttributes(\"<select\", params) . \">\" . PHP_EOL;\n\n        if useEmpty {\n            /**\n             * Create an empty value\n             */\n            let code .= self::echoOption(emptyValue)\n                . emptyText\n                . \"</option>\" . PHP_EOL;\n        }\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Tag/Select.zep#L99-L135","documentation":"Even when 'using' is present for a select built from object options, it must be structured data: Tag\\Select rejects a $using that is neither array nor object with Phalcon\\Tag\\Exception (\"The 'using' parameter should be an array\") — despite the message, an object also passes; strings and other scalars throw. The intended shape is ['valueColumn', 'labelColumn'].","triggerScenarios":"'using' => 'id' — a single column string instead of an array; 'using' => 0 or another scalar; dynamically built params where the using list is sometimes a bare string.","commonSituations":"Single-column selects where developers pass the column name directly; config-driven column names arriving as a string like 'id,name' instead of an array.","solutions":["Wrap it in an array with value and label columns: 'using' => ['id', 'name']","Normalize dynamic params before the call: $params['using'] = (array) $params['using'];","Split comma strings: array_map('trim', explode(',', $using))"],"exampleFix":"// before\necho \\Phalcon\\Tag::selectStatic(['categoryId', 'using' => 'id'], Categories::find());\n\n// after\necho \\Phalcon\\Tag::selectStatic(\n    ['categoryId', 'using' => ['id', 'name']],\n    Categories::find()\n);","handlingStrategy":"validation","validationCode":"if (isset($params['using']) && !is_array($params['using']) && !is_object($params['using'])) {\n    $params['using'] = (array) $params['using']; // 'id' -> ['id']\n}\n\necho \\Phalcon\\Tag::selectStatic($params, $resultset);","typeGuard":"function isValidUsingParameter($using): bool\n{\n    return is_array($using) || is_object($using);\n}","tryCatchPattern":"try {\n    echo \\Phalcon\\Tag::selectStatic($params, $resultset);\n} catch (\\Phalcon\\Tag\\Exception $e) {\n    if (str_contains($e->getMessage(), \"'using' parameter should be an array\")) {\n        $params['using'] = (array) $params['using'];\n        echo \\Phalcon\\Tag::selectStatic($params, $resultset);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Always pass 'using' as an array of [valueColumn, labelColumn]","Normalize dynamically built params (cast or split comma strings) before tag calls","Add view tests for every select built from ORM resultsets"],"tags":["phalcon","tag","select","parameter-validation"],"backgroundTag":"invalid-parameter-type","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}