TYPO3 extbase等于不起作用

时间:2017-03-17 03:23:54

标签: typo3 extbase

我只需要获取type = 0的记录但是在查询之后,我获得了所有类型的所有记录

  public function findPeople() {
        $query = $this->peopleRepository->createQuery();
        $query->equals('type', 0);
        $query->setOrderings(
            array(
                'uid' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
            )
        );
        return $query->execute();
    }


    /**
     * action people
     *
     * @return void
     */
    public function listAction()
    {
        $people = $this->findPeople();
        $this->view->assign('people', $people);
    }

1 个答案:

答案 0 :(得分:4)

您需要在存储库方法中添加matching()方法:

  public function findPeople() {
    $query = $this->peopleRepository->createQuery();
    $query->matching($query->equals('type', 0));
    $query->setOrderings(
        array(
            'uid' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
        )
    );
    return $query->execute();
}

请参阅:https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/3-implement-individual-database-queries.html