有'('但没有')'时的mysql查询错误

时间:2019-01-28 11:39:57

标签: mysql laravel

$q = "select * from product where decription = ?";
$param = 'package ( 2 chicken wings, 3 salad';

$result = DB::select($q, array($param));

存在一个错误查询,因为参数字符串没有')'。 如何防止查询字符串中是否有“(”但没有“)”?

错误信息:语法错误或访问冲突:1064语法错误,意外的$ end

1 个答案:

答案 0 :(得分:0)

看,您没有$ query ..那将是$ q而不是$ query

答案是$result = DB::select($q, array($param));