我有4个excel文件,每个文件包含1000行。我将其合并为4000,这样可以节省一些时间。但是,如果我导入合并的文件,它将返回的错误General error: 1390 Prepared statement contains too many placeholders。但是,当我将它们一一插入时,它可以工作。我不知道为什么会返回这样的错误,它们甚至在每一列中都具有相同的值。有人可以告诉我该错误怎么办吗?需要帮助。非常感谢
我正在使用laravel maatwebsite excel软件包。
我的导入代码
{
if($request->hasFile('template')){
$path = $request->file('template')->getRealPath();
$data = \Excel::load($path)->get();
if($data->count() > 0){
$rows = $data->toArray();
foreach ($rows as $row) {
$level = '';
$stack = '';
$unit = '';
$gunit = '';
$street = '';
$block_unit = '';
//DONT MIND THIS FUNCTION HERE
if (strpos($row['address'], '#') !== false) {
$unit = explode("#",$row['address']);
$gunit = $unit[1];
$block = explode(" ",$unit[0],2);
if(isset($unit[1])) {
$x = explode("-",$unit[1]);
$level = $x[0];
$stack = $x[1];
$street = $block[1];
$block_unit= $block[0];
}
}
elseif(strpos($row['address'], ' ') !== false){
$unit = explode(" ",$row['address']);
$block = explode(" ",$unit[0],2);
if(isset($unit[1])) {
$x = explode("-",$unit[1]);
$level = '';
$stack = '';
$x = preg_replace('/[0-9]+/', '', $row['address']);
$street = $x.substr($street,1);
$block_unit= $block[0];
}
}
else{
$level = '';
$stack = '';
$unit = '';
$gunit = '';
$block_unit = '';
$street = '';
}
//END
$inserts[]=[
'transtype' => 'RESI',
'project_name' => $row['project_name'],
'unitname' => $gunit,
'block' => $block_unit,
'street' => $street,
'level' => $level,
'stack' => $stack,
'no_of_units' => $row['no._of_units'],
'area' => $row['area_sqm'],
'type_of_area' => $row['type_of_area'],
'transacted_price' => $row['transacted_price'],
'nettprice' => $row['nett_price'],
'unitprice_psm' => $row['unit_price_psm'],
'unitprice_psf' => $row['unit_price_psf'],
'sale_date' => $row['sale_date'],
'contract_date' => $row['sale_date'],
'property_type' => $row['property_type'],
'tenure' => $row['tenure'],
'completion_date' => $row['completion_date'],
'type_of_sale' => $row['type_of_sale'],
'purchaser_address_indicator' => $row['purchaser_address_indicator'],
'postal_district' => $row['postal_district'],
'postal_sector' => $row['postal_sector'],
'postal_code' => $row['postal_code'],
'planning_region' => $row['planning_region'],
'planning_area' => $row['planning_area'],
];
}
}
if(empty($inserts)){
dd('Request data does not have any files to import.');
}
else {
\DB::table('xp_pn_ura_transactions')->insert($inserts);
dd('record inserted');
}
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。