orm
orm copied to clipboard
Sharding capability
It would be great to have more information about sharding/using multiple databases.
Doctrine uses a ShardManager interface to get the right connection (using the distribution value) implicitly. It is also possible to do it explicitly to get the right entity manager, for example with Symfony:
class UserController extends AbstractController {
public function index()
{
// Explicit way to deal with the "custom" entity manager
$products = $this->getDoctrine()
->getRepository(Product::class, 'customer')
->findAll()
;
}
}
This solution could probably be setup easily, it would be nice to have an example in the documentation.
More information:
- https://www.doctrine-project.org/projects/doctrine-dbal/en/2.11/reference/sharding.html
- https://symfony.com/doc/current/doctrine/multiple_entity_managers.html
- https://stackoverflow.com/questions/11463517/using-relationships-with-multiple-entity-managers/11494543#11494543
- https://labs.madisoft.it/doctrine-sharding/
- https://docs.citusdata.com/en/v9.3/sharding/data_modeling.html