php - Laravel querybuilder updateOrInsert method leads to error

I got a curl request that calling external API and i got to save the response from it. I already saved the previous results and now i want to create a cronjob that calls the function everyday to update the data from our api source. But when i replaceinsert
intoupdateOrInsert
method by laravel's querybuilder, It leads me to
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
Here is my controller.
public function getProjectList(){
$this->getToken();
$request_time = Carbon::now()->format('YmdHis');
$sign = md5($this->token.$request_time);
$url = 'https://cgi.singmap.com/project/queryProject?request_time='.$request_time.
'&token='.$this->token.'&sign='.$sign.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);
$trimmed = $response['datas'];
// dd($trimmed);
foreach ($trimmed as $res){
$inserts[]=[
'projectId' => $res['projectId'],
'projectName' => $res['projectName'],
'country' => $res['country'],
'location' => $res['location'],
'propertyGroup' => $res['propertyGroup'],
'latitude' => $res['country'],
'longitude' => $res['country'],
'unitsNum' => $res['unitsNum'],
'launchDate' => $res['launchDate'],
'launchDateAltText' => $res['launchDateAltText'],
'mainImage' => $res['mainImage'],
'min_price' => $res['min_price'],
'max_price' => $res['max_price'],
'streetAddress' => $res['streetAddress'],
'tenure' => $res['tenure'],
'developer' => $res['developer'],
'streetAddress' => $res['streetAddress'],
];
}
// \DB::table('xp_ecoprop_projectlist')->insert($inserts);
\DB::table('xp_ecoprop_projectlist')->updateOrInsert($inserts);
dd('Data Inserted');
}
Response example
array:3 [в–ј
"code" => "0"
"msg" => "SUCCESS"
"datas" => array:127 [в–ј
0 => array:21 [в–ј
"propertyGroup" => "D09, D10, D11, D21"
"country" => "Singapore"
"launchDateAltText" => "Launched"
"latitude" => "1.30509901046753"
"galleryLatitude" => "1.30492997169495"
"relationId" => "175"
"launchDate" => "1555689600000"
"galleryLongitude" => "103.828666687012"
"unitsNum" => 154
"mainImage" => "https://img.singmap.com/upload/broke/2029c11d79004b5e915809fbd6e19f7b/0275d26811574de68834663514ee2878/imgs/ffc6d2435f5c43828eb9d2200c6186ff.png"
"max_price" => 35000000.0
"min_price" => 0.0
"streetAddress" => "86, 88 Orchard Boulevard"
"location" => "D10 - Tanglin / Holland"
"completionDate" => "1640966400000"
"developer" => "Granmil Holdings Pte Ltd"
"projectName" => "Boulevard 88 (D10)"
"projectId" => "0275d26811574de68834663514ee2878"
"tenure" => "Freehold"
"projectTitle" => "Boulevard 88 (D10)"
"longitude" => "103.827575683594"
]
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: 403 this action is unauthorized.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.