2014-11-01 13 views
0

我想知道是否有人可以帮助我得到一个错误。Laravel - insertGetId显示参数不匹配错误

我有以下代码:

$suburbInsert = array(); 
$suburbInsert[] = array(

    'name' => $postalCode . ' ' . $suburbName, 
    'suburb_name' => $suburbName, 
    'pcode' => $postalCode 

); 

$suburbID = DB::table('suburbs')->insertGetId($suburbInsert); 

当我虽然运行,IAM收到以下错误

{"error":{"type":"ErrorException","message":"preg_replace(): Parameter mismatch, pattern is a string while replacement is an array","file":"\/var\/www\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/helpers.php","line":990}} 

任何帮助,将不胜感激

回答

1

你正在创建$suburbInsert为一组数组。

相反的:

$suburbInsert = array(); 
$suburbInsert[] = array(
    ... 
); 

只要做到:

$suburbInsert = array(
    ... 
); 
+0

哦,这就是工作...谢谢:) – BigJobbies 2014-11-01 02:50:47