Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $file = file_get_contents($'file.json');
  2. $jsonData = json_decode($file, true);
  3.  
  4. $check = $this->getMyRepository()->findOneBy([
  5. 'first_name' => $firstName,
  6. 'last_name' => $lastName
  7. ]);
  8.  
  9. foreach ($jsonData as $data) {
  10.  
  11. if ($check) {
  12. continue;
  13. } else {
  14. $new = new MyEntity();
  15. $new->setFirstName($data->getFirstName());
  16. $new->setLastName($data->getLastName());
  17. $this->em->persist($new);
  18. }
  19. }
  20. }
  21. $this->em->flush();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement