如何在Symfony2上编写查询

时间:2017-05-04 05:31:24

标签: php mysql sql symfony symfony-2.8

如何在我的存储库中编写它以便能够在我的控制器中使用它?

NSString *string1 = @"Case Number \n 1 \n SKU Barcode";
NSString *string2 = @"Case Number";
if ([string1 rangeOfString:string2].location !=NSNotFound) {

    NSLog(@"matched");}
else
{ NSLog(@"not matched");}

}

1 个答案:

答案 0 :(得分:0)

试试这个:

public function findWhateverYouWant()
{
    $em = $this->getEntityManager();

    $rsm = new ResultSetMappingBuilder($em);

    $sql = sprintf('SELECT COUNT(id_pnc) 
                    FROM programmevol p
                    WHERE p.id_pnc IN ( SELECT id_pnc 
                                        FROM programmevol A 
                                        WHERE p.id_pnc=A.id_pnc
                                        HAVING COUNT(*)>1
                                       )', 
                    $rsm->generateSelectClause()
                   );

    $query = $em->createNativeQuery($sql, $rsm);

    return $query->getResult();
}