调用未定义的方法MongoDB \ Driver \ ReadConcern :: isDefault()

时间:2017-11-19 09:20:48

标签: php mongodb laravel

I really don't know what the problem is!

class RegisterController extends Controller
{
    public function store(request $request)
    {

        $reg = Register::all();
        var_dump($reg);

和注册

class Register extends Moloquent
{

    protected $connection='mongodb';
    protected $collection='registers';

}

2 个答案:

答案 0 :(得分:0)

显然,这是从最新版本的库mongodb/mongodb中获取的方法。

此方法仍可在版本中使用:1.1.2

要暂时解决此问题,请通过替换以下内容来更新composer.lock文件:

{
    "name": "mongodb/mongodb",
    "version": "1.1.2",
    "source": {
        "type": "git",
        "url": "https://github.com/mongodb/mongo-php-library.git",
        "reference": "a307dd60e71e1291c60927ea4f3a1905146063f5"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/a307dd60e71e1291c60927ea4f3a1905146063f5",
        "reference": "a307dd60e71e1291c60927ea4f3a1905146063f5",
        "shasum": ""
    },
    "require": {
        "ext-mongodb": "^1.2.0",
        "php": ">=5.4"
    },
    "require-dev": {
        "phpunit/phpunit": "^4.8"
    },
    "type": "library",
    "autoload": {
        "psr-4": {
            "MongoDB\\": "src/"
        },
        "files": [
            "src/functions.php"
        ]
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "Apache-2.0"
    ],
    "authors": [
        {
            "name": "Jeremy Mikola",
            "email": "jmikola@gmail.com"
        },
        {
            "name": "Hannes Magnusson",
            "email": "bjori@mongodb.com"
        },
        {
            "name": "Derick Rethans",
            "email": "github@derickrethans.nl"
        }
    ],
    "description": "MongoDB driver library",
    "homepage": "https://jira.mongodb.org/browse/PHPLIB",
    "keywords": [
        "database",
        "driver",
        "mongodb",
        "persistence"
    ],
    "time": "2017-02-16T18:40:32+00:00"
},

并运行composer install

答案 1 :(得分:0)

我通过这样设置composer.json来解决了这个问题:

{
  "require": {
    "mongodb/mongodb": "1.1.2"
  }
}

然后运行composer update