Connection.php第673行中的Laravel 5 QueryException:

时间:2016-05-25 15:49:11

标签: mysql laravel laravel-5.2

我收到此错误:

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正在删除'类别'在将其发送到查询之前。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

private function updateSettingsTable($request, $requestType,$settingType)
{
  $redundants = Preference::where('tenant_id', session('tenant')) ->where('setting_type', "'".$settingType."'")->delete();
 }