Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // src/BlobBundle/Repository/PostRepository.php
- namespace BlogBundle\Repository;
- use BlogBundle\Entity\Post;
- use Doctrine\ORM\EntityRepository;
- class PostRepository extends EntityRepository
- {
- /**
- * Store post to database
- *
- * @param Post $post
- */
- public function persist(Post $post)
- {
- $this->getEntityManager()->persist($post);
- $this->getEntityManager()->flush();
- }
- /**
- * Search posts with given author's name
- *
- * @param string $name
- * @return array
- */
- public function findByAuthorName($name)
- {
- return $this->createQueryBuilder('posts')
- ->select('posts')
- ->join('posts.author', 'author')
- ->where('author.name = :name')
- ->setParameter('name', $name)
- ->getQuery()
- ->getResult();
- }
- }
- http://github.com/shfx17
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement