{"record":{"id":"0eb6cdc7ae8fe9bc","repo":"laravel/framework","slug":"invalid-binding-type-type","errorCode":null,"errorMessage":"Invalid binding type: {$type}.","messagePattern":"Invalid binding type: (.+?)\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Query/Builder.php","lineNumber":4662,"sourceCode":"     */\n    public function getRawBindings()\n    {\n        return $this->bindings;\n    }\n\n    /**\n     * Set the bindings on the query builder.\n     *\n     * @param  list<mixed>  $bindings\n     * @param  \"select\"|\"from\"|\"join\"|\"where\"|\"groupBy\"|\"having\"|\"order\"|\"union\"|\"unionOrder\"  $type\n     * @return $this\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function setBindings(array $bindings, $type = 'where')\n    {\n        if (! array_key_exists($type, $this->bindings)) {\n            throw new InvalidArgumentException(\"Invalid binding type: {$type}.\");\n        }\n\n        $this->bindings[$type] = $bindings;\n\n        return $this;\n    }\n\n    /**\n     * Add a binding to the query.\n     *\n     * @param  mixed  $value\n     * @param  \"select\"|\"from\"|\"join\"|\"where\"|\"groupBy\"|\"having\"|\"order\"|\"union\"|\"unionOrder\"  $type\n     * @return $this\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function addBinding($value, $type = 'where')\n    {","sourceCodeStart":4644,"sourceCodeEnd":4680,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Query/Builder.php#L4644-L4680","documentation":"setBindings() replaces the bindings for one named slot. The slots are a fixed set: select, from, join, where, groupBy, having, order, union, unionOrder. Passing any other $type fails array_key_exists() and throws InvalidArgumentException, because an unknown slot would silently lose its bindings.","triggerScenarios":"->setBindings([1, 2], 'wheres'), ->setBindings([1], 'limit'), or any typo in the type string.","commonSituations":"Typos like 'wheres' instead of 'where'; passing 'limit' or 'offset' which are not binding slots; copy-paste from getBindings() output with the wrong key.","solutions":["Use one of the documented types: 'select', 'from', 'join', 'where', 'groupBy', 'having', 'order', 'union', 'unionOrder'.","Rely on addBinding() / the fluent where() calls instead of setBindings() unless you really need to overwrite a slot.","Double-check the type against array_keys($query->getRawBindings()) in debugging."],"exampleFix":"// before\n->setBindings([1, 2], 'wheres')\n\n// after\n->setBindings([1, 2], 'where')","handlingStrategy":"validation","validationCode":"const VALID_BINDINGS = ['select','from','join','where','groupBy','having','order','union','unionOrder'];\nif (! in_array($type, VALID_BINDINGS, true)) {\n    throw new InvalidArgumentException('Invalid binding type: ' . $type);\n}\n$query->setBindings($bindings, $type);","typeGuard":"/** @param 'select'|'from'|'join'|'where'|'groupBy'|'having'|'order'|'union'|'unionOrder' $type */\nfunction isValidBindingType(string $type): bool\n{\n    return in_array($type, ['select','from','join','where','groupBy','having','order','union','unionOrder'], true);\n}","tryCatchPattern":null,"preventionTips":["Prefer the fluent where()/select()/orderBy() APIs which route bindings automatically.","Avoid setBindings() unless you genuinely need to overwrite a slot.","Cross-check the type against $query->getRawBindings() when debugging."],"tags":["query-builder","bindings","database","validation"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}