Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3924

Querying with the Query Builder

$
0
0

I'M USING SYMFONY 4.12 I'm trying to write queries to filter my jobs(I've job table ,départements one) I first try with experience but I'm stuck in here is my offerController:

/**
 * @Route("/offres", name="offres")
 * @param Request $request
 * @param PaginatorInterface $paginator
 * @param FormFactoryInterface $formFactory
 * @return Response
 */
public function offreSearch(Request $request, PaginatorInterface $paginator ,FormFactoryInterface $formFactory):Response
{

    $datas =new OffreEmploi();
    $formFilter=$formFactory->create(OfferFilterForm::class,$datas);
    $offres = $this->repository->findSearch($datas);

    $formFilter->handleRequest($request);

    return $this->render('offre/index.html.twig', [
        'controller_name' => 'OffreController',
        'offres' => $offres,
        'formulaire'   =>$formFilter->createView(),

    ]);
}

} and this is my query in the offerRepositor:

  public function findSearch(OffreEmploi $data):?array
{
    $query = $this->createQueryBuilder('o');
    if ($data->getExperience() !== null) {

        $query
            ->where('o.experience > :experience')
            ->setParameter('experience', $data->getExperience());

    }
    return $query->getQuery()->getResult();
}

when it come to enter any number IT give the same thing it show all the jobs stored in the database,I don't know where the problem is, some one can help me to solve this . THE RESULT


Viewing all articles
Browse latest Browse all 3924

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>