Matt C.
Well-known member
I'm trying to save content from a JSON file to an entity and each piece of content has its own id which is an 8 character string.
Here is part of the code that runs through each piece of content. When it runs through each piece of content, it's supposed to check if the id exists before saving the entity.
When it runs through each piece of content, its supposed to check if the id exists before saving the entity.
I keep getting this error:
Any help would be appreciated. Thank you.
Here is part of the code that runs through each piece of content. When it runs through each piece of content, it's supposed to check if the id exists before saving the entity.
Code:
foreach($response['data'] as $key => $value)
{
$entryId = $value['id'];
$service = $value['account']['service'];
$timestamp = $value['timestamp'];
$nick = $value['account']['developer']['nick'];
$role = $value['account']['developer']['role'];
$content = $value['content'];
$url = $value['url'];
if ($params[$entryId])
{
$newEntry = $this->assertEntryExists($params[$entryId]);
}
else
{
$newEntry = \XF::app()->em()->create('AH\DevTracker:Entry');
$newEntry->bulkSet([
'entry_id' => $entryId,
'service' => $service,
'timestamp' => $timestamp,
'nick' => $nick,
'role' => $role,
'content' => $content,
'url' => $url
]);
}
$newEntry->save();
}
When it runs through each piece of content, its supposed to check if the id exists before saving the entity.
I keep getting this error:
Code:
All entry_id values must be unique.
Any help would be appreciated. Thank you.