Doctrine 2, query inside entities

前端 未结 5 1574
自闭症患者
自闭症患者 2020-12-13 16:51

How do I perform queries in an entity?

namespace Entities\\Members;

/**
 * @Entity(repositoryClass=\"\\Entities\\Member\\MembersRepository\")
 * @Table(name         


        
5条回答
  •  情书的邮戳
    2020-12-13 17:20

    Your question was really hard to understand, please try and work on how you structure your questions in the future. For instance, you say "return back the same result" but "filter", which could mean anything. Do you want to use the same result set (why on earth would you ever choose to do that), and just use array_filter or array_walk to filter the results or do you actually want to use a conditional join? It's incredibly ambiguous.

    Anyway.. answer ( after reading your question 4 times).

    $q = $qb->select ( "m","w" )
                ->from ( "Members", "m" )
                ->leftJoin( "m.commententries","w",'WITH', 'w.id = :id')
                ->setParameter ( "id", $id )
                ->getQuery ();
    

提交回复
热议问题