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

Bastian Waidelich mailinglistDELETEME at wwwision.de
Tue Jul 22 13:19:24 CEST 2008


Karsten Dambekalns wrote:

Hi Karsten

 > Intuitive?

Yeah, looks good!
Though I don't really understand why you have to pass the query-object 
to the "subquery" in:

$posts = $query
     ->matching('title', '~', '%FLOW3%')
     ->orMatching($query
       ->matching('content', '~', 'cool')
       ->andMatching('title', '~', '%TYPO3')
     )
     ->execute();

It could be just

$posts = $query
     ->matching('title', '~', '%FLOW3%')
     ->orMatching(
       ->matching('content', '~', 'cool')
       ->andMatching('title', '~', '%TYPO3')
     )
     ->execute();

or am I missing something?


 > Easy (enough)?

Yes, I think so. Maybe the criteria operator could be a Constant. So 
instead of:

->matching('title', '~', '%FLOW3%')

something like:

->matching('title', F3_PHPCR_Query::OPERATOR_LIKE, '%FLOW3%')

or even a new method:

->matchingLike('title', '%FLOW3%')

This way we'd had better IDE-support (code-hinting) and the chance of 
typos could be reduced.


 > Misses something?

You don't specify any action (like "select" or "retrieve") in your 
examples. So how would a writing query look like?

Did you have a look at the Query language of Doctrine: 
http://www.phpdoctrine.org/documentation/manual/0_11/de?chapter=dql-doctrine-query-language
I know, this is not about relational Databases, but Doctrine does a 
pretty good job in creating query trees. Maybe a source for further 
inspiration..

All the best
Bastian


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