[FLOW3-general] fetch from Repository with QueryResult as parameter
John Small
flow3.tiny69 at net-con.net
Mon Aug 20 17:31:42 CEST 2012
Hello,
created a workaround,
would be nice QueryInterface->in() could handle that ;)
/**
* Finds all objects matching
*
* @param \TYPO3\FLOW3\Persistence\QueryResultInterface $entries
* @return \TYPO3\FLOW3\Persistence\QueryResultInterface The query
result
*/
public function findRelatedEntries($entries) {
$query = $this->createQuery();
$entriesArray = array();
foreach($entries as $entry) {
$entriesArray[] =
$this->persistenceManager->getIdentifierByObject($entry);
}
return $query->matching(
$query->in('entryfield', $entriesArray)
)
->execute();
}
Am 17.08.2012 21:56, schrieb John Small:
> Hi there,
>
> trying to get Flow3 1.1 working ;)
> I'd like to obtain a subset from a repository related to a QueryResult
> from a previous one out of a different model.
> These models are connected with @ORM\ManyToOne so I have that
> /flow3_persistence_identifier/ in my Table where I'd like to fetch from.
>
> I created this in the repository class, after a few other failing
> version:
>
> /**
> * Finds all objects matching
> *
> * @param \TYPO3\FLOW3\Persistence\QueryResultInterface $entries
> * @return \TYPO3\FLOW3\Persistence\QueryResultInterface The query
> result
> */
> public function findRelatedEntries($entries) {
> $query = $this->createQuery();
>
> return $query->matching(
> $query->in('entryfield', $entries)
> )
> ->execute();
> }
>
>
> But, this only works when $entries is an array of strings or objects
> having the __toString() method,
> I would like to use the hidden /flow3_persistence_identifier/ field
> 'cos that's the only field I have here.
> :s
>
> Is there a decent way to fetch a subset, or what did I miss ?
>
> thx
>
--
kind regards
More information about the FLOW3-general
mailing list