简体   繁体   中英

TYPO3 Extbase query with JOIN

I have table items, and table item_categories. Every Item can have more than one category. I have created Extbase extension with those two models. I want to filter items by category, how can I create query for that? It should look like this:

LEFT JOIN item_categories ON items.uid = item_categories.item_uid

You have to create an own query in your itemsRepository:

protected function findByCategory($category) {
  $query = $this->createQuery();
  $query->matching(
    $query->contains('category', $category)
  );
  return $query->execute();
}

This will return all items with at least the given category, assuming that you have an 1:n relation between items and category.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM