【问题标题】:TYPO3 Extbase - Query only records within a certain uid rangeTYPO3 Extbase - 仅查询特定 uid 范围内的记录
【发布时间】:2017-03-03 19:26:09
【问题描述】:

如何仅呈现特定 uid 范围内的记录?假设我只想呈现它的 uid 的记录,例如高于 100 低于 200

/**
 * action list
 *
 * @return void
 */
public function listAction() {

$this->view->assign('records', $this->testRepository->findAll());

}

我是否需要使用 MathUtility 并且它是 isIntegerInRange ...但是如何使用?

【问题讨论】:

    标签: typo3 extbase typo3-7.6.x


    【解决方案1】:

    在存储库中使用您自己的函数。

    控制器

    /**
     * action list
     *
     * @param integer $minUid
     * @param integer $maxUid
     * @return void
     */
    public function listAction() {
    
        $this->view->assign('records', $this->testRepository->findUidRange($minUid,$maxUid));
    
    }
    

    存储库

    /**
     * Find records filtered by uid from to
     *
     * @param integer $minUid
     * @param integer $maxUid
     * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result
     */
    public function findUidRange($minUid = NULL, $maxUid = NULL) {
        $query = $this->createQuery();
        return $query->matching(
                $query->logicalAnd(
                        $query->greaterThan('uid', $minUid),
                        $query->lessThan('uid', $maxUid),
                        $query->equals('deleted', 0)
                ))->execute();
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-26
      • 1970-01-01
      • 1970-01-01
      • 2014-08-22
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多