@Dziamid is half right.
Technically, you cannot join two tables to split the database. But you can fake this for any real intervention.
Configure several database connections:
//databases.yml all: items_db: class: sfDoctrineDatabase param: dsn: mysql://login: passwd@localhost /items stores_db: class: sfDoctrineDatabase param: dsn: mysql://login: passwd@localhost /stores
Determine the correct connection for each model.
//schema.yml Item: connection: items_db columns: store_id: integer(4) relations: Store: local: store_id foreign: id foreignAlias: Items Store: connection: stores_db columns: name: string(255)
Now you can use your Doctrine models as usual:
// like this $item = new Item(); $store = new Store(); $store->save(); $item->setStore($store); // or like this $item->getStore();
The only limitation is that you CANNOT perform joins in DQL queries.
$query = Doctrine_Query::create() ->from('Store s') ->leftJoin('s.Items i') ->fetchAll();
But you can load relationships using Doctrine_Collections.
$stores = Doctrine::getTable('Store')->findAll();
This works the same as Doctrine_Query.
source share