一个应用程序中的锂连接(MongoDb、CouchDb 和 Mysql)

发布于 2024-12-03 01:54:26 字数 100 浏览 6 评论 0原文

我正在开发电子商务应用程序。是否可以编写一个在不同连接上工作的锂应用程序,基本上是 MongoDb 或 CouchDb 和 MySQL?我们怎样才能做到这一点?您对实现这一目标有何建议?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

給妳壹絲溫柔 2024-12-10 01:54:26

我不确定我的理解是否正确。

如果您只是想同时使用更多连接到不同的数据库,这是很容易实现的。您可以一次定义更多连接(查看默认的connections.php引导文件以及lithium\core\Environment类的文档)。

如果您想在上述所有数据库上运行整个应用程序,请继续阅读...

一般来说回答这个问题并不容易,但这里有一些想法:

如您所知,Lithium 为您提供了一个数据库抽象层,公开 CRUD 过程的通用方法。在开发过程中这很好(您不必为每个数据库学习新的接口),您很快就会遇到需要数据库特定功能的情况。

这可能会引起关系数据库之间的兼容性问题,但混合关系数据库和非关系数据库几乎是不可能的。当然,您可以并排使用它们,但提供抽象确实很难。例如,您将如何在 MySQL 中查询嵌套文档(就像在 MongoDB 中所做的那样)?您可以编写一个包装器来尝试模拟这一点,但您不应该尝试这样做。

也就是说,如果您确实必须这样做,您可以通过编写包装器代码来实现它,并省略非常具体的依赖于数据库的功能。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文