[TYPO3-team-core-v5] RFC: fluent interface to query persistence
Karsten Dambekalns
karsten at typo3.org
Tue Jul 22 15:17:54 CEST 2008
Hi Sebastian.
Sebastian Kurfürst wrote:
> I would really like it the following way:
> $query = $this->queryFactory->create('F3_Blog_Domain_Blog');
> $blogs = $query->matching(
> eq('name', $name),
> or(
> like('title', '%FLOW3%'),
> like('content', '%FLOW3%')
> )
> )->execute();
>
> Problem: there would need to be function "eq", and "or", "like", ...
> which sucks.
But there aren't. And which is why the mock objects in PHPUnit are
somewhat hard to use:
$mock->expects($this->once())->method('...')->will($this->returnValue(NULL));
All the extra $this's make this hard to read, but I doubt there is a way
around this in PHP. You cannot even define a method named and()
currently in a class (or for any other PHP keyword).
> We could as well parse the whole query tree as a string, but that is
> ugly too...
Argh. :)
Regards,
Karsten
More information about the TYPO3-team-core-v5
mailing list