I have a project which uses three different databases the first one is the main database which I can make changes to the second two belong to different projects but I need to access data in them. The following is a simplified directory structure.
Src
-
AppBundle
- Entity
- BusinessUnitsFox
- DriverMax
- VehicleFox
- Model
- BusinessUnitInterface
- UDODriverInterface
- VehicleInterface
- Entity
-
FoxBundle
- Entity
- BusinessUnits
- Vehicle
- Entity
- MaxBundle
- Entity
- DriverMax
- Entity
Below are the files for the abstract class and interface for BusinessUnits the Vehicle and Driver are similar.
<?php
// src/AppBundle/Model/BusinessUnitInterface.php
namespace AppBundle\Model;
interface BusinessUnitInterface
{
/**
* @return string
*/
public function __toString();
}
The Abstract Class
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FoxBundle\Entity\BusinessUnit as BaseBU;
use AppBundle\Model\BusinessUnitInterface;
/**
* @ORM\Entity
* @ORM\Table(name="business_unit_fox")
*/
class BusinessUnitFox extends BaseBU implements BusinessUnitInterface
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* {@inheritDoc}
* @see \AppBundle\Model\BusinessUnitInterface::__toString()
*/
public function __toString() {
return $this->getId();
}
}
config.yml
# Doctrine Configuration
doctrine:
dbal:
default_connection: maxdb
connections:
maxdb:
# ...
foxdb:
# ...
max2db:
# ...
orm:
resolve_target_entities:
AppBundle\Model\VehicleInterface: AppBundle\Entity\VehicleFox
AppBundle\Model\UDODriver: AppBundle\Entity\DriverMax
AppBundle\Model\BusinessUnit: AppBundle\Entity\BusinessUnitFox
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: maxem
entity_managers:
maxem:
connection: maxdb
mappings:
AppBundle:
BWTCalendarBundle: ~
BWTFMBundle: ~
BWTHealthCheckBundle: ~
BWTSkytrackBundle: ~
BWTTelematicsBundle: ~
foxem:
connection: foxdb
mappings:
FoxBundle: ~
max2em:
connection: max2db
mappings:
MaxBundle: ~
When I do A SQL call I get the following error
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'telematics.vehicle_fox' doesn't exist
So I ran doctrine:schema:update
and got the following error
[Doctrine\Common\Persistence\Mapping\MappingException]
Class 'AppBundle\Model\BusinessUnitInterface' does not exist
Is there anything that I am missing?
Is it possible to declare a OneToMany relationship from the abstract class?