【发布时间】:2015-02-27 17:03:39
【问题描述】:
这是我的代码,您可以在其中看到删除命令的 where 条件为空
try{
DB::table('t_users')->where('id', '=', '')->delete();
} catch (Exception $e){
return Functions::createErrorResponse(400, 'E200', $e->getCode() . ' - ' . $e->getMessage());
}
但它在这里没有显示任何错误。如果我某些错误的表名那么它会给我错误..
{
"error": {
"code": 400,
"type": "E200",
"message": "42S02 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'globalops.t_charts' doesn't exist (SQL: delete from `t_charts` where `id` = )"
}
}
没关系,
任何人都可以告诉我为什么即使我将代码保留在 try-catch 事件中它也不会显示任何错误的原因。 我应该做点别的吗..?
【问题讨论】:
-
我不认为在 SQL 中有
WHERE id = ""是错误的。 ;) -
没错。您可以传递一个空字符串。