LeWestopher / cakephp-monga

A CakePHP 3.x plugin for accessing MongoDB NoSQL data stores
MIT License
17 stars 3 forks source link

Error: Call to undefined method DebugKit\Database\Log\DebugLog::getContext() #6

Closed mohamadfikri closed 7 years ago

mohamadfikri commented 7 years ago

Upon installation, this is the error I get which seems to be triggered from this code:

$mongodb = $cake_monga->connect();

This is the full error message:

Error: Call to undefined method DebugKit\Database\Log\DebugLog::getContext() File /vendor/lewestopher/cakephp-monga/src/Database/MongoConnection.php Line: 296

Thanks!

LeWestopher commented 7 years ago

Are you using DebugKit's database logger in conjunction with CakeMonga? If that's the case, it is not compatible.

Can you attach an example of the datasource you are using?

A quick and dirty fix that should work: disable query logging before connecting to your instance, like:

$cake_monga = ConnectionManager::get('mongodb');
$cake_monga->logQueries(false); // disable logging
$mongodb = $cake_monga->connect();
mohamadfikri commented 7 years ago

Hi @LeWestopher

This is my first time trying out MongoDB.

Your solution solves the issue I bumped into.

This is the simple datasource I used:

'mongo_db' => [
            'className' => 'CakeMonga\Database\MongoConnection'
            ]

I did try to use the advanced one:

'mongo_db' => [
            'className' => 'CakeMonga\Database\MongoConnection',
            'logger' => null,
            'authMechanism' => null,
            'authSource' => null,
            'connect' => true,
            'connectTimeoutMS' => 60000,
            'db' => null,
            'dns' => 'mongodb://localhost:27017',
            'fsync' => null,
            'journal' => null,
            'gssapiServiceName' => 'mongodb',
            'username' => null,
            'password' => null,
            'readPreference' => null,
            'readPreferenceTags' => null,
            'replicaSet' => null,
            'secondaryAcceptableLatencyMS' => 15,
            'socketTimeoutMS' => 30000,
            'ssl' => false,
            'w' => 1,
            'wTimeoutMS' => 10000
        ]

But this error came out:

SSL can only be 'true' or 'false'

It's fine when I comment out the SSL declaration.

Thanks again for the great work!

basantk commented 7 years ago

I have made connection successfully but i want to log query in file so how can i do that ?