gpt4 book ai didi

php - 调用未定义的方法 MongoDB\Driver\Cursor::current()

转载 作者:行者123 更新时间:2023-12-04 08:27:03 27 4
gpt4 key购买 nike

我在 PHP 中遇到这个错误:

Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Cursor::current()`.
这似乎与 the documentation 矛盾.
我可以显示我的代码,但是,我调用方法 current()对于 MongoDB 游标。

最佳答案

几周前刚刚添加了此功能:

MongoDB\Driver\Cursor has historically only implemented Traversable and provided an internal iterator (not to be to the Iterator userland class). PHP 8 required that we implement either Iterator or IteratorAggregate directly (PHPC-1690), although PHP also provides an internal iterator for extensions to make that easier.


That said, we should consider providing a proper Iterator implementation on the Cursor to remove our reliance on the internal iterator class for PHP 8 and present a consistent API for all supported versions.


https://jira.mongodb.org/browse/PHPC-1691 (2020 年 11 月 4 日决议)
确保您拥有的任何软件包都是最新的,或者 install from source如有必要。

关于php - 调用未定义的方法 MongoDB\Driver\Cursor::current(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65207914/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com