[Flow] Query on OneToMany relation
Alexander Götz
goetz.al at gmail.com
Sat Apr 26 15:56:34 CEST 2014
Hello,
I have two Entities a CalendarEntry and a OneToMany relationship with the Attendees.
/**
* @Flow\Entity
*/
class CalendarEntry {
/**
* @var \DateTime
* @Flow\Validate(type="NotEmpty")
*/
protected $start;
/**
* @var \Doctrine\Common\Collections\ArrayCollection<\My\Example\Domain\Model\Attendee>
* @ORM\OneToMany(mappedBy="calendarEntry", cascade={"all"})
* @ORM\Column(nullable=true)
*/
protected $attendees;
}
/**
* @Flow\Entity
*/
class Attendee {
/**
* @var \My\Example\Domain\Model\CalendarEntry
* @ORM\ManyToOne(inversedBy=„attendees")
*/
protected $calendarEntry;
/**
* @var \My\Example\Domain\Model\Member
* @ORM\ManyToOne
*/
protected $member;
/**
* @var integer
*/
protected $status;
}
So now I need a function in the calendarEntry Repository that returns all calendarEntries for a member where status is not eg 7 sorted by „start“. The following code was my first try but it won’t return anything.
$query = $this->createQuery();
$result = $query->matching(
$query->logicalAnd(
$query->equals('attendees.member', $member),
$query->logicalNot(
$query->equals('attendees.status‘, 7)
)
)
)->setOrderings(array(
’start', \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING
))
->execute();
return $result;
Is it even possible without using SQL syntax?
Hope someone can help me.
Greetings
Alex
More information about the Flow
mailing list