【问题标题】:Class 'MongoDB\BSON\Regex' not found [duplicate]找不到类“MongoDB\BSON\Regex”[重复]
【发布时间】:2016-10-15 10:45:01
【问题描述】:

我尝试来自 php.net 的示例:-http://php.net/manual/en/class.mongodb-bson-regex.php

在 php 中执行以下代码时

$regex = new MongoDB\BSON\Regex ( '^Al');
$cursor = $collection->find(array('name' => $regex));
//iterate through the cursor

然后 php 显示错误 Class 'MongoDB\BSON\Regex' not found 请帮助我如何解决这个问题

【问题讨论】:

  • 好吧,您需要以某种方式包含类定义才能使用该类。你是怎么做到的?
  • 我怎样才能包含这个类 MongoDB\BSON\Regex
  • 请给出示例类 MongoDB\BSON\Regex 使用
  • 您需要该类的类定义(“代码”),然后在使用该类之前include()该文件。
  • 反斜杠??我认为语法错误。

标签: php mysql regex mongodb


【解决方案1】:

您可能会发现只有 Eclipse 将其标记为问题,但是当您在 Web 服务器上运行它时就可以了。

如果是这种情况,那么您的答案就在这里: How to have eclipse resolve php classes in MongoDB\BSON namespace?

【讨论】:

    猜你喜欢
    • 2016-10-05
    • 2017-12-05
    • 2015-03-24
    • 2016-08-19
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    相关资源
    最近更新 更多