[Flow] class-Query

Steffen Wickham steffen at gaming-inc.de
Tue May 21 10:41:29 CEST 2013


Hello Mario,

I think "cut & paste" isn't suitable for queries, as they have to be
written specifically for your model. Just for example, here are some
queries written by me:

Find all "Match" objects between today until a given \DateTime object:
public function findAllUntil( \DateTime $until ) {
    $query = $this->createQuery();
    $today = new \DateTime();

    return $query->matching(
        $query->logicalAnd(
            $query->greaterThanOrEqual('kickoff', $today),
            $query->lessThanOrEqual('kickoff', $until)
        )
    )->execute();
}


One of my first queries, which returns all confirmed assignments for a
specific "Referee" object between two given dates
public function
findConfirmedAssignmentsForRefereeBetweenTwoDates(\AFSVN\Basic\Domain\Model\Referee
$referee, \DateTime $startdate, \DateTime $enddate) {
    $query = $this->createQuery();

    $sql = $query->matching(
        $query->logicalAnd(
            $query->equals('refereeReference', $referee),
            $query->greaterThanOrEqual('matchReference.kickoff',
$startdate),
            $query->lessThanOrEqual('matchReference.kickoff', $enddate),
            $query->equals('status',
\AFSVN\Basic\Domain\Model\RefereeAssignment::STATUS_ACCEPTED)
        )
    )
        ->execute();

    return $sql;
}


Cheers,
Steffen




Am 19.05.13 17:52, schrieb mario chiari:
> Hello
>
> thanks. Yes, of course, althoug I was looking for a bunch of common
> situation examples to cut&paste. 
>
> cheers
> mario
>
> On Fri, 2013-05-17 at 20:00 +0200, Steffen Wickham wrote:
>> Hello Mario,
>>
>> please have a look in the definitive guide, chapter Persistance:
>> http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/Persistence.html
>>
>> cheers,
>> Steffen
>>
>>
>> Am 17.05.2013 18:38, schrieb mario chiari:
>>> Hi
>>>
>>> I see
>>> http://typo3.org/api/flow/TYPO3/Flow/Persistence/Doctrine/class-Query.html 
>>>
>>> is there a tutorial page, with common situation examples?
>>> thanks
>>> mario
>>>
> ...
>
>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list