doumeng3188 2019-02-19 06:54
浏览 238

游标不能为PHP产生多个迭代器mongodb错误

I have a simple record that should return based on a query. As soon as I try to get the results I get the following error:

Cursors cannot yield multiple iterators

The code I have is very simple:

    $db = \core\databaseUtilities\getDbConnection();

    $filter = [ 'email' => $email ]; 
    $query = new \MongoDB\Driver\Query($filter);

    $res = $db->executeQuery($db->dbName.".users", $query);
    $records = $res->toArray();

It fails on the last line.

I found some code examples on the web on how to query on they all pretty much looked the same. Here is the reference I used: http://php.net/manual/en/class.mongodb-driver-cursor.php

  • 写回答

2条回答 默认 最新

  • dongxueji2838 2019-02-19 07:15
    关注

    I found the issue and it had nothing to do with the code. I am posting the answer as other may come across the same issue. It had to do with my IDE Visual Studio code. However, I assume this may not be restricted to my IDE. The problem was I had a watch on $res->toArray(); so by the time the code go to the last line in my example it was trying to iterate again. As soon as I removed the watch my issues went away no code changes necessary.

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题