BlogBundle/Entity/Repository/PostRepository.php
public function findPost($search)
    {
        // select
        $qb = $this->getQueryBuilder()
            ->select('p, pTrans')
            ->join('p.translations', 'pTrans')
            ;    
        
        
        // search
        if (!empty($search)) {
            $qb->where('pTrans.title LIKE :search')
                ->orWhere('pTrans.description LIKE :search')
                ->setParameter('search', '%'.$search.'%');
        }

        $qb->orderBy('p.published', 'DESC');

        return $qb->getQuery()->getResult();
    }
public function findPost($search)
    {
        // select
        $qb = $this->getQueryBuilder()
            ->select('p, pTrans')
            ->join('p.translations', 'pTrans')
            ;    
        
        
        // search
        if (!empty($search)) {
            $qb->where('pTrans.title LIKE :search')
                ->orWhere('pTrans.description LIKE :search')
                ->setParameter('search', '%'.$search.'%');
        }

        $qb->orderBy('p.published', 'DESC');

        return $qb->getQuery()->getResult();
    }
public function findPost ( $ search ) { // select $ qb = $ this -> getQueryBuilder ( ) -> select ( 'p, pTrans' ) -> join ( 'p.translations' , 'pTrans' ) ; // search if ( ! empty ( $ search ) ) { $ qb -> where ( 'pTrans.title LIKE :search' ) -> orWhere ( 'pTrans.description LIKE :search' ) -> setParameter ( 'search' , '%' . $ search . '%' ) ; } $ qb -> orderBy ( 'p.published' , 'DESC' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find all rows filtered for DataTables

@param string $search        The search string
@param int    $sortColumn    The column to sort by
@param string $sortDirection The direction to sort the column

@return \Doctrine\ORM\Query
Find all rows filtered for DataTables