我收到此错误:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens (SQL: delete from `preferences` where `tenant_id` = 154 and `setting_type` = Category and 1 = 1)
当我使用此功能时:
private function updateSettingsTable($request, $requestType, $settingType)
{
$redundants = Preference::where('tenant_id', session('tenant'))->where('setting_type', $settingType)->delete();
}
并将其称为:
$this->updateSettingsTable($request, 'categories', 'Category');
好像Laravel正在删除'类别'在将其发送到查询之前。有什么想法吗?
答案 0 :(得分:0)
试试这个:
private function updateSettingsTable($request, $requestType,$settingType)
{
$redundants = Preference::where('tenant_id', session('tenant')) ->where('setting_type', "'".$settingType."'")->delete();
}