Koshceyshka

Untitled

Dec 13th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. namespace app\controllers;
  4.  
  5. use Doctrine\ORM\Tools\Setup;
  6. use App\Entities\Student;
  7. use Doctrine\ORM\EntityManager;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Doctrine\ORM\EntityRepository;
  10.  
  11.  
  12.  
  13. class MainController extends AppController {
  14.  
  15.  
  16.  // public function __construct(EntityManagerInterface $entityManager)
  17.  //    {
  18.  //        $this->repository = $entityManager->getRepository('Student');
  19.  //    }
  20.  
  21.  
  22. public function index(){
  23.         // echo 'Hello test';
  24.     }
  25.    
  26.  
  27. public function new(){
  28.  
  29.  
  30. // $studentRepository = $this->$entityManager->getRepository('Student');
  31. // $student = $productRepository->findAll();
  32. // echo $student->getId();
  33.  
  34.  
  35. $name = 'Ura';
  36. $surname = 'Greachka';
  37.  
  38. $manager = new EntityManager();
  39. $entityManager = $manager->getDoctrine()->getManager();
  40. $student = new Student();
  41. $student->setName($name);
  42. $student->setSurname($surname);
  43. $entityManager->persist($student);
  44. $entityManager->flush();
  45.  
  46.  
  47.    
  48. }
  49.  
  50.  
  51. public function remove(){
  52.  
  53. }
  54.  
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment