我需要使用SequelizeJS的承诺,但我想确保我的代码干净......
我的代码:
public function OfferIndex(Request $request)
{
//working solution
$em = $this->getDoctrine()->getManager();
$queryBuilder = $em->createQueryBuilder();
$queryBuilder->select(array('o', 't', 'r', 'c'))
->from('BackBundle\Entity\offer', 'o')
->leftJoin('o.offerType', 't')
->leftJoin('o.offerRegion', 'r')
->leftJoin('o.offerCategory', 'c')
;
if (isset($_REQUEST['offerKey'])) {
$queryBuilder
->where('CONCAT(o.name,o.technologies,t.name,r.name,c.name) LIKE :search')
->setParameter('search', '%' . $_REQUEST['offerKey'] . '%');
}
$query = $queryBuilder->getQuery();
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query, /* query NOT result */
$request->query->getInt('page', 1)/*page number*/,
2/*limit per page*/
);
return $this->render('FrontBundle:pages:Offre d\'emploi et de stage .html.twig',array(
'pagination' => $pagination
));
}
如何使用嵌套承诺?