【问题标题】:namespaces cannot have embedded null characters命名空间不能嵌入空字符
【发布时间】:2018-03-09 07:42:40
【问题描述】:

申请详情: 我正在开发一个 Web 应用程序,其中我使用 php 作为服务器端语言,使用 mongodb 作为数据库。我正在使用 php mongodb 库来连接 mongodb 数据库。

问题: 我可以使用 mongoDB 库从后端成功创建数据库连接。但是当我运行查找查询时,我收到以下错误消息:

致命错误:未捕获的异常 带有消息“命名空间”的“MongoDB\Driver\Exception\RuntimeException” 不能嵌入空字符 C:\wamp64\www\analytic_script\vendor\mongodb\mongodb\src\Operation\Find.php 180号线

谁能告诉我可能的解决方案。这是发生错误的find.php函数。

public function execute(Server $server)
{
    $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;

    **// Error is occuring at this line**
    $cursor = $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery(), $readPreference);

    if (isset($this->options['typeMap'])) {
        $cursor->setTypeMap($this->options['typeMap']);
    }

    return $cursor;
}

【问题讨论】:

  • 听起来databaseNamecollectionName 之一为空,或者根据错误消息包含null (\0) 字符。
  • 好的@KevinAdistambha,感谢您的cmets。在深入研究时,我发现 php mongodb 扩展与我正在使用的 mongo 包不兼容。当我升级扩展版本时,它可以完美运行。无论如何,谢谢。

标签: php mongodb mongodb-query


【解决方案1】:

升级php7扩展mongodb 1.1.1 => mongodb 1.5.3

【讨论】:

  • 一些解释为什么这会有帮助。
猜你喜欢
  • 2020-01-14
  • 1970-01-01
  • 2019-09-04
  • 1970-01-01
  • 2021-12-23
  • 1970-01-01
  • 1970-01-01
  • 2012-09-29
  • 1970-01-01
相关资源
最近更新 更多