Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $file = file_get_contents($'file.json');
- $jsonData = json_decode($file, true);
- $check = $this->getMyRepository()->findOneBy([
- 'first_name' => $firstName,
- 'last_name' => $lastName
- ]);
- foreach ($jsonData as $data) {
- if ($check) {
- continue;
- } else {
- $new = new MyEntity();
- $new->setFirstName($data->getFirstName());
- $new->setLastName($data->getLastName());
- $this->em->persist($new);
- }
- }
- }
- $this->em->flush();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement