Skip to content

Using the connection everywhere #58

Closed
@nbertal

Description

@nbertal

Hi again,
I would like to use the MongoDB connection outside of a Model (ie. a custom class not dependant of a specific collection).

So far:
DB::getMongoDB() does'nt work (dependency issue, couldn't resolve)
DB::connection('mongodb') returns NULL

What is the best practice?

A) still use your IoC ? Then how can I proceed?
B) Open the connection using the original Mongo PHP library, everytime I need it ? Isn't it efficient because it might trigger multiple connections instead of a single instance?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions