Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use both MySQL Models and MongoDB models #6

Closed
adamlc opened this issue Jul 16, 2013 · 6 comments
Closed

Use both MySQL Models and MongoDB models #6

adamlc opened this issue Jul 16, 2013 · 6 comments

Comments

@adamlc
Copy link

adamlc commented Jul 16, 2013

Our application uses both MySQL and MongoDB connections, but I'm afraid I can't get both working together.

I have tried various things such as tweaking namespaces etc. If I remove the 'Jenssegers\Mongodb\MongodbServiceProvider' from providers the MySQL eloquent models work as expected.

Is there any way to get them working side by side? My guess is the ConnectionResolver has been changed and its breaking MySQL models.

Im quite new to Laravel so not 100% if the above this the problem.

@jenssegers
Copy link
Contributor

Did you register an alias, or only the serviceProvider?

@adamlc
Copy link
Author

adamlc commented Jul 17, 2013

Hi,

I only put in the service provider as per the docs. The alias for Eloquent is still:

'Eloquent' => 'Illuminate\Database\Eloquent\Model',

Thanks
Adam

@jenssegers
Copy link
Contributor

Do you get this error?

Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given

I will check how I can solve this problem.

jenssegers added a commit that referenced this issue Jul 17, 2013
@jenssegers
Copy link
Contributor

The ConnectionResolver was indeed overwritten by the Mongo model. Update your version and it should work :)

@adamlc
Copy link
Author

adamlc commented Jul 17, 2013

Awesome! I can confirm that the above fix sorted the issue.

Many thanks :)

@rkang30
Copy link

rkang30 commented Mar 3, 2016

I have set mysql as my defaut db and set mongodb as a second. When I print DB::connection('mongodb'), it was still pull my mysql db name. Could u help me with this issue please?

Smolevich pushed a commit that referenced this issue Jan 30, 2020
…bute

Merged from halaei:fix-test-asser-object-not-has-attribute
alcaeus pushed a commit to alcaeus/laravel-mongodb that referenced this issue Aug 16, 2023
…tests (mongodb#6)

* PHPORM-45 Add Query\Builder::toMql() to simplify comprehensive query tests
* Move Query/Builder unit tests to a dedicated test class
alcaeus pushed a commit that referenced this issue Aug 22, 2023
…tests (#6)

* PHPORM-45 Add Query\Builder::toMql() to simplify comprehensive query tests
* Move Query/Builder unit tests to a dedicated test class
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this issue Sep 2, 2024
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this issue Sep 2, 2024
…s-attribute

Merged from halaei:fix-test-asser-object-not-has-attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants