php - doctrine storing the resultset? -
i'm new doctrine , i'm running problem. here is:
i have following model/entity:
<?php namespace models; /** @entity @table(name="teams") @haslifecyclecallbacks */ class team { ... /** @onetomany(targetentity="teammember", mappedby="team") */ private $members; ... function getteamsileadforgame($user, $game) { $q = $this->doctrine->em->createquery("select t, tm models\team t join t.members tm tm.user = ?1 , t.game = ?2 , tm.is_leader = ?3 order t.name asc"); $q->setparameter(1, $user); $q->setparameter(2, $game); $q->setparameter(3, 1); try { return $q->getresult(); } catch (\doctrine\orm\noresultexception $e) { return null; } } }
as can see, there link teammember entity. in function wrote, i'm trying teams current user has is_leader flag set 1.
this query executes fine , result expect be.
now onto problem. further down in controller try following:
$postteam = $this->em->find('models\team', $this->input->post('team'));
the team data returns correct, when call $postteam->getmembers() returns 1 row (the 1 is_leader = 1) instead of members of team.
so seems doctrine keeping other function in of head? i'm confused why is.
so said, controller looks this:
$teams = models\team::getteamsileadforgame($this->user->getid(), $tournament->getgame()->getid()); // checks on returned teams $postteam = $this->em->find('models\team', $this->input->post('team')); $postteam->getmembers();
when remove $teams = models....... line, works fine again. seems me doctrine filters internal resultset line, , searches in resultset on.
any ideas on how fix this? thnx
i figured out finaly :d
it turns out had lazy loading. once set 'fetch=eager' @ link towards members, worked fine.
hope of people having same problem...
Comments
Post a Comment