Doktrini kullanarak çoklu veritabanları arasında kolon toplama

0 Cevap php

Let's say I have 2 tables in different databases that represent one model
(one-to-one column aggregation).

şema:

Table1:
  connection: conn1
  columns:
    property1: string
Table2:
  connection: conn2
  columns:
    table1_id: integer
    property2: string
  relations:
    Table2:
      local: table1_id
      foreign: id
      type: one
      foreignType: one

Yani bir tablodan doktrin koleksiyon alabilirsiniz:

$objects = Doctrine::getTable('Table1')->findAll()

Ve sonra başka bir tablodan her nesnenin özelliklerini alınamadı:

foreach ($objects as $object) 
{
  $object->getProperty2();
}

But, this will result in too many sql requests from Table2 (one request for each object). What I'm trying to achieve is one sql request from each table.

If both tables where in one database, a simple join would do the trick. Any suggestions?

0 Cevap