I have two databases in my project.
First database named : global
Second database named : first_db
Global database has a table Car
and Moto
and the first_db database has tables Items
, Bus
and Ship
.
Below the post you see the annotations of table Items.
* @ORM\Table(name="Items")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap( {
* "car" = "Project\ItemBundle\EntityGlobal\Car",
* "moto" = "Project\ItemBundle\EntityGlobal\Moto",
* "bus" = "Bus",
* "ship" = "Ship",
* }
* )
When I create query with DQL it doesn't understand that car
and moto
are in the other database. I have found a beta solution if entities Car
and Moto
set annotation with this method
* @ORM\Table(name="global.Moto")
* @ORM\Table(name="global.Car")
On update schema I don't have a problem, but it's not very safe. I know i can write native queries but I am not sure its the optimal way.
What is one better way to do this not using native queries?