带有json字段的symfony2 QueryBuilder

带有json字段的symfony2 QueryBuilder,symfony,Symfony,对不起我的英语。 我有点受阻了,希望你能帮我。 我的实体中有一个json字段。我想和querybuilder一起获得profil1的地位。 BDD中my表中my字段的示例:(按如下方式保存) 大概是这样的: $queryBuilder = $entityManager->createQueryBuilder() ->select('e') ->from('ACMEDemoBundle:YourEntity', 'e');

对不起我的英语。 我有点受阻了,希望你能帮我。 我的实体中有一个json字段。我想和querybuilder一起获得profil1的地位。 BDD中my表中my字段的示例:(按如下方式保存)

大概是这样的:

    $queryBuilder = $entityManager->createQueryBuilder()
            ->select('e')
            ->from('ACMEDemoBundle:YourEntity', 'e');
    $result = $queryBuilder
                    ->getQuery()->getResult();

    foreach ($result as $entity)
    {
        $jsonObject =  json_decode($entity->getJsonField()); //where jsonField is the name of the field containing the json
        $profile1Statut = $jsonObject['Profil1']['statut'];
    } 

也许你也想做一些精神检查。根据你桌子的大小,这可能有点过分。

有点?我会进行全面扫描。
    $queryBuilder = $entityManager->createQueryBuilder()
            ->select('e')
            ->from('ACMEDemoBundle:YourEntity', 'e');
    $result = $queryBuilder
                    ->getQuery()->getResult();

    foreach ($result as $entity)
    {
        $jsonObject =  json_decode($entity->getJsonField()); //where jsonField is the name of the field containing the json
        $profile1Statut = $jsonObject['Profil1']['statut'];
    }