拉拉维尔 DB::插入 参数编号无效



我正在尝试通过变量在我的表中插入表单的值。 当我尝试使用一个值时,没关系,但随后使用 2,这不起作用。

SQLSTATE[HY093]:参数编号无效(SQL:插入到 ....

但这是我的代码和 SQL 请求,我不明白为什么这不起作用。

DB::insert('insert into recherchesDuJour (UserIp,'."$ListeDesColonnesARemplir".') values (?,'."$ListeDesPointsDInterrogation".' )', [$UserIp , $ListeDesValeurs]);

我的print_r变量

print_r($ListeDesColonnesARemplir . '/');

print_r($ListeDesValeurs . '/');
print_r($ListeDesPointsDInterrogation . '/');
die();
NaceCode,Langue/a:2:{i:0;s:4:"7724";i:1;s:4:"7762";},s:2:"fr";/?,?/

我有相同数量的列,"?"和值,所以我不明白。

感谢您的帮助,对不起我的英语不好。

您必须将$ListeDesValeurs字符串转换为数组:

DB::insert('...', array_merge([$UserIp], explode(',', $ListeDesValeurs)));

最新更新