[TYPO3-team-core-v5] RFC: fluent interface to query persistence

Sebastian Kurf?ürst sebastian at typo3.org
Tue Jul 22 14:28:17 CEST 2008


Hey Karsten,

>   // create a query for Post instances
> $query = $this->queryFactory->create('F3_Blog_Domain_Post');
>   // title or content must contain FLOW3
> $posts = $query
>     ->matching('title', '~', '%FLOW3%')
>     ->orMatching('content', '~', '%FLOW3%')
>     ->execute();
We would need a precedence here - so what is the difference between:

$query
	->matching('a', '=', $a)
	->matchingOr('b', '=', $b)
	->matching('c', '=', $c);

and

$query
	->matching('a', '=', $a)
	->matching('c', '=', $c);
	->matchingOr('b', '=', $b)

(assuming that "matching" is "matchingAnd")


That's why I would prefer

$query->matches(
	$op->or(
		$op->equals('a', $a),
		$op->equals('b', $b)
	),
	$op->equals('c', $c);
)
Basically
$query->matches(...) is the same as
$query->matches($op->and(...));

$query->
	->
	->

I still do not like the many $op's inside, but I think the query is 
easier to read than your examples.

Greets,
Sebastian


More information about the TYPO3-team-core-v5 mailing list