Question

I have 2 different kind of storage for a CMS that I am building. A relational database and a content repository (PHPCR + Doctrine ODM). I have a User which is stored inside the relational database and I have a Post document which is stored inside PHPCR. How would I get all posts for all active users.

Psuedo code (for demonstration purpose):

$qb = $this->createQueryBuilder('Document\Post', 'post');
$qb->join('post.user', 'user'); // We join on the table inside a relation database
$qb->where('user.active = 1');

$posts = $qb->getQuery()->execute(); // All posts objects of active users

Is this even possible? Or do I need to use 1 type of storage (relational or PHPCR) for all of my data?

Hope somebody can help me out!

Was it helpful?

Solution

You can not join over the different databases. If you do not have thousends and thousands of users, you could just map them into PHPCR. Otherwise you could do two queries. One on the ORM to fetch your user(s) and then one on PHPCR-ODM to fetch all posts that have a username that is one of the users you are looking for.

For links from ORM to PHPCR, you can use the "referenceable" feature of documents and store the UUID in the relational database. You can find a document by UUID:

$dm->find(null, $uuid)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top