BlogBundle/Entity/Repository/PostRepository.php
public function findOneLastPost($site)
    {
        // select
        $qb = $this->getQueryBuilder()
                ->select('p.id, p.title, p.description, p.slug, p.published, i.path as image_path')
                ->leftJoin('p.images', 'i')

                ->andWhere('p.highlighted=1')
                ->setMaxResults(1)
                ->orderBy('p.published', 'DESC');
        return $qb->getQuery()->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
    }
public function findOneLastPost($site)
    {
        // select
        $qb = $this->getQueryBuilder()
                ->select('p.id, p.title, p.description, p.slug, p.published, i.path as image_path')
                ->leftJoin('p.images', 'i')

                ->andWhere('p.highlighted=1')
                ->setMaxResults(1)
                ->orderBy('p.published', 'DESC');
        return $qb->getQuery()->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
    }
public function findOneLastPost ( $ site ) { // select $ qb = $ this -> getQueryBuilder ( ) -> select ( 'p.id, p.title, p.description, p.slug, p.published, i.path as image_path' ) -> leftJoin ( 'p.images' , 'i' ) -> andWhere ( 'p.highlighted=1' ) -> setMaxResults ( 1 ) -> orderBy ( 'p.published' , 'DESC' ) ; return $ qb -> getQuery ( ) -> getOneOrNullResult ( \ Doctrine \ ORM \ Query :: HYDRATE_ARRAY ) ; }
Find last Post with image for a specyfic site

@param type $site
@return array
Find last Post with image for a specyfic site