2017-01-16 60 views
0

在我的仓库为extentsion我有下面的代码没有结果:库查询 - > setLimit(4)返回在​​某些情况下

function findByTyp($typ, $not, $gender) { 
     $query = $this->createQuery(); 
     return $query->matching(
         $query->logicalAnd(
          $query->equals('pid', 96), 
          $query->equals('typ', $typ), 
          $query->logicalNot($query->equals('uid', $not)), 
          $query->equals('gender', $gender) 
         ) 
        ) 
        ->setOrderings (Array('sort' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)) 
        ->setLimit(4) 
        ->execute(); 
    } 

现在在特定的情况下,这应该与1项返回查询它。但不知何故,它不返回任何项目。但是,当我删除->setLimit(4)它返回正确的项目。

现在这对我来说没什么意义。在其他情况下,它的工作方式应该如何。那么,怎样才能->setLimit(4)从查询中删除的项目时,有没有更多然后4个项目(在本例中仅有1)

+0

请看看查询生成被发送到数据库。这应该告诉我们更多。 – pgampe

回答

-1

我无法找到一个答案,到目前为止所以这里是我的

解决方法:

我不存储库中使用->setLimit(4),但只在模板中使用第4项:

<f:for each="{collection}" as="collectionItem" iteration="collectionCount"> 
     <f:if condition="{collectionCount.index}<4"> 
       .... 
     </f:if> 
    </f:for> 
相关问题