IN and NOT IN query in TYPO3 extbase extension

When we works with extbase extension development in TYPO3, we have to works with queries.
TYPO3 have their own query builder and it convents the result into object. So whatever we need to user using JOIN query  we can do it just by their object without manual query.

But when I was searching for different queries like IN, NOT IN etc, I was found it difficult to find so I am writing this post.

You can use IN query as per below :

$query = $this->createQuery();
       $query->matching(
               $query->logicalAnd(
                         $query->in('uid', $contrains),
               )
       );
 $query->execute();
You can user NOT IN query as per below :


$query = $this->createQuery();
       $query->matching(
               $query->logicalAnd(
                          $query->logicalNot(
                                   $query->in('uid', $contrains),
                          ) 
               )
       );
 $query->execute();

You can add additional condition of logical AND and logical OR along with above IN and NOT IN query.

1 comments:

Post a Comment

Thanks for your comment.