0

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!

Steffen Brem
  • 1,738
  • 18
  • 29

1 Answers1

1

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)
dbu
  • 1,497
  • 9
  • 8
  • Is PHPCR with Doctrine ODM slow? I hope not, I am building a large scale CMS system. Which will probably have over 100.000 documents. I will use elastic search to index the most. How would PHPCR do it with 100.000 documents? – Steffen Brem May 09 '14 at 10:24
  • You definitely want to look into jackalope-jackrabbit then. Jackrabbit is the storage engine behind Adobe Experience Manager (former Adobe CQ, former Day Communique). It can handle large amounts of data. It uses lucene internally, but you can't directly access that lucene, so running a separate ElasticSearch seems sane. The only general hint i have is to avoid more than 10'000 direct child nodes under any single parent. But best discuss further on symfony-cmf-users@googlegroups.com to reach other users who build projects with PHPCR-ODM. – dbu May 10 '14 at 11:27
  • (In case you are using doctrine outside symfony, you are still welcome to ask there, its for now the biggest community of PHPCR-ODM users ;-) – dbu May 10 '14 at 11:28