Use of symfony2 mongodb
PHP中文网
PHP中文网 2017-05-16 16:44:45
0
1
710

I was reading the symfony2 mongodb documentation recently, and I felt a little confused about how to use it.

Mongodb has odm one-to-one, one-to-many, many-to-many relationship mapping similar to mysql orm, which is also more convenient to use.

But if you use mysql and mongodb in combination, to get the mongodb data from mysql, according to the doctrine one-to-one official document, you need to associate mysql and mongodb through the subscriber and LifecycleEventArgs events.
There are no detailed examples for one-to-many and many-to-many. Later, it was discovered that when using one-to-many and many-to-many, an intermediate table needs to be generated in mysql and mongodb. Through the LifecycleEventArgs event, the intermediate table becomes a bridge for communication between mysql and mongodb

So the maintenance of this intermediate table is more troublesome. For example, if you delete mongodb data, you must also update the intermediate table. In addition, if there are many tables associated with two databases, wouldn't there also be many intermediate tables? ?

For smyfony2, use MySQL and mongodb in combination. Is it better to use a single database? ? ? If the two are used in combination, the stored data must not be highly dependent? ? ? In that case, does it feel cumbersome to use mysql and mongodb on the doctrine official website? ?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
世界只因有你

To be simple and reliable, you should definitely put each business in a single storage; Doctrine provides an object-oriented operation interface for cross-type storage, which is not to say that it is recommended.

Since they are all in different storages, it is more appropriate to use API to operate.

$user->getComments();
// VS
$comments = $commentManager->getCommentsForUser($user);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!