2011-08-18 56 views

回答

2

什麼你想是不是「技術上」的支持作爲主義設計特徵。

所以,如果你想做到這一點,你會與傳統的PostgreSQL:

SELECT table1.field1, table1.field2, table2.field2, 
    FROM table1 INNER JOIN 
     dblink('dbname=db2 port=5432 host=domainname2 
       user=someuser password=somepwd', 
       'SELECT field1, field2, 
       FROM other_table') 
      AS table2(field1 int, field2 char(25)) 
     ON table1.field3 = table2.field1; 

您將取代單一連接這是默認的帶兩個連接您的config.php文件。

<?php 

Doctrine_Manager::connection('mysql://[email protected]/doctrine_db1', 'db1'); 
Doctrine_Manager::connection('mysql://[email protected]/doctrine_db2', 'db2'); 

然後,你修改的模式像這樣的東西:

--- 
Table1: 
    tableName: db1.table1 
    connection: db1 
    columns: 
     filed1: integer 
     field2: string(255) 
     field3: integer 
    relations: 
     Table2: 
     foreignType: one 
     onDelete: CASCADE 

Table2: 
    tableName: db2.table2 
    connection: db2 
    columns: 
     field1: integer 
     field2: string(25) 

然後,你將數據像正常後建立數據庫。然後,只需進行常規建模,確保使用所需字段指定表格,就像使用任何常規查詢一樣。

Doctrine Cross Database Joins在Doctrine博客上詳細討論。所以你可以檢查一下。

+0

正確的鏈接上面提到的學說博客條目是: http://www.doctrine-project.org/blog/cross-database-joins.html 我試圖編輯後糾正鏈接,但它沒有達到編輯所需的最小「6」字符。 – s1d

相關問題