Question

I was on my way for the Development of an Ecommerce app. Is it possible to write a lithium application that works on different connections basically MongoDb or CouchDb and MySQL? How can we do it and what are your tips on achieving it?

Was it helpful?

Solution

I'm not sure if I understand you right.

If you just want to use more connections at the same time to different databases, this is easily possible. You can just define more connections at once (take a look at the default connections.php bootstrap file and also at the documentation for the lithium\core\Environment class).

If you want to run your whole application on all the database mentioned above, read on...

It is not easy to answer this question in general, but here are some thoughts on this:

As you may know, Lithium provides you with a database abstraction layer which exposes general methods for the CRUD process. As nice this is during development (you don't have to learn new interfaces for every database), you soon come to a point where you need database specific features.

This may raise compatiblitiy problems between relational databases, but is nearly impossible for mixing relational and non-relational databases. Of course you can use them side-by-side, but providing abstractions is really hard. For example, how would you query on nested documents (like you do in MongoDB) in MySQL? You could write a wrapper that tries to emulate this, but you shouldnt try to.

That said, if you really have to do this, you may achieve it with writing wrapper code and leave out very specific database-dependend features.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top