2

I've looked all around for a way to join multiple databases using doctrine 2, but all i've found until now are work arounds but i couldn't understood how to modify my config file to do so

//my config.php file
$isDevMode = true;
$path = array(ROOTPATH."/src");
$config = Setup::createAnnotationMetadataConfiguration($path, $isDevMode);


// database configuration parameters
$conn = array(
    'driver'   => 'pdo_mysql',
    'user'     => 'root',
    'password' => '',
    'dbname'   => 'test',
);

// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);

On this topic here, the accepted answer said that i have to create multiple entity managers,which it's logic , but when i got here, on the PHP tab(i'm using PHP as annotations), i was lost.Couldn't figure out how to change my already existing config file. Then i found a documentation about joining databases, here , but that looks very different from what i have , probably because is an older version and i don't know if this still work, but i haven't tested that because i don't use yaml,and there's nowhere an explanation on how to do that without using a framework or yaml,xml annotations.

Community
  • 1
  • 1
Petru Lebada
  • 2,167
  • 8
  • 38
  • 59
  • Doctrine does not support this out of the box since cross database queries only work for mysql and even then only work of both databases are on the same server. You can however "fool" doctrine by including the database name as part of the table name when mapping your entities: database_name.table_name. Of course this has it's own issues. – Cerad May 02 '17 at 11:54

0 Answers0