Example #1
0
 public function actionDoctrineExample()
 {
     $articles = $this->em->getDao(Article::getClassName());
     $article = new Article();
     $article->title = "The Fight Club";
     $articles->save($article);
     $article = $articles->find(1);
     $this->template->article = $article->title;
     Debugger::dump($article);
     $this->redirect('Homepage:default');
 }
 public function renderDefault()
 {
     $this->template->anyVariable = 'any value';
     $dao = $this->EntityManager->getRepository(Article::getClassName());
     $this->template->articles = $dao->findAll();
     //		$post = new Posts();
     //		$post->title = 'New title';
     //		$post->text = 'New text New textNew text';
     //		$post->created_at = new \Nette\Utils\DateTime;
     //
     //
     //		$this->EntityManager->persist($post);
     //		$this->EntityManager->flush();
     //		$dao = $this->EntityManager->getRepository(Posts::getClassName());
     //		$dao->setTitle('test');
     //		$dao->__call('set', ['title' => 'my title']);
     //		dump($dao->__isset('title'));
     //		$dao->__set('title', 'test');
 }
Example #3
0
 public function __construct(Kdyby\Doctrine\EntityManager $em)
 {
     $this->em = $em;
     $this->articles = $em->getRepository(Article::getClassName());
     // $this->articles = $em->getRepository(App\Article::getClassName()); // for older PHP
 }