本文介绍了TYPO3:信息库-> findAll()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用后端模块构建扩展.当我调用 findAll ()方法时,它将返回一个"QueryResult"对象.

I am building an extension with a backend module. When I call the findAll() method it returns a "QueryResult" object.

我尝试使用 findByUid ()检索对象,并且确实可以正常工作.

I tried to retrieve objects with findByUid() and it does work.

我在打字稿中设置了存储pid:

I set the storage pid in the typoscript:

plugin.tx_hwforms.persistence.storagePid = 112

我也可以在拼写对象浏览器中看到它.

I can also see it in the typoscript object browser.

我还将其添加到我的存储库类中:

I also added this to my repository class:

public function initializeObject()
    {
        $defaultQuerySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
        $defaultQuerySettings->setRespectStoragePage(false);
        $this->setDefaultQuerySettings($defaultQuerySettings);
    }

,以便忽略存储pid ...它仍然无法正常工作,findAll并没有返回应有的实体数组

so that the storage pid is ignored ...It's still not working, findAll doesn't return an array of entites as it should

推荐答案

存储库必须findAll方法返回QueryResult.仅返回单个对象(findOneByXYZ)的方法将返回其他任何内容.

Repository must return a QueryResult from the findAll methods. Only methods which return a single object (findOneByXYZ) will return anything else.

以下所有操作将导致QueryResult加载其包含的实际结果.在执行其中一项操作之前,将不会加载任何结果,并且调试QueryResult不会产生任何信息(原始查询除外).

All of the following operations will cause a QueryResult to load the actual results it contains. Until you perform one of these, no results are loaded and debugging the QueryResult will yield no information except for the original Query.

  • $queryResult->toArray();
  • $queryResult->offsetGet($offset);$queryResult[$offset];
  • $queryResult->offsetExists($offset);
  • $queryResult->offsetSet($offset, $value);$queryResult[$offset] = $value;(但请注意,使用QueryResult自己这样做是不合逻辑的).
  • $queryResult->offsetUnset($offset);unset($queryResult[$offset]);(再次,自己动手使用不合逻辑)
  • $queryResult->current()->key()->next()->prev()->rewind()->valid()都可以直接调用,也可以在开始迭代QueryResult时被调用.
  • $queryResult->toArray();
  • $queryResult->offsetGet($offset); and $queryResult[$offset];
  • $queryResult->offsetExists($offset);
  • $queryResult->offsetSet($offset, $value); and $queryResult[$offset] = $value; (but be aware that doing this yourself with a QueryResult is illogical).
  • $queryResult->offsetUnset($offset); and unset($queryResult[$offset]); (again, illogical to use this yourself)
  • $queryResult->current(), ->key(), ->next(), ->prev(), ->rewind() and ->valid() which can all be called directly or will be called if you begin iterating the QueryResult.

请注意,->getFirst()->count()不会引发原始查询,并且如果尚未填充结果,则不会填充结果.相反,他们将执行优化的查询.

Note that ->getFirst() and ->count() do not cause the original query to fire and will not fill results if they are not already filled. Instead, they will perform an optimised query.

摘要:获取QueryResult时,必须以某种方式触发它,这通常在开始呈现结果集时发生.它不是预填充数组;它不是预填充数组.它是一个动态填充的迭代器.

Summa summarum: when you get a QueryResult you must trigger it somehow, which normally happens when you begin to render the result set. It is not a prefilled array; it is a dynamically filled Iterator.

这篇关于TYPO3:信息库-> findAll()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 12:55