I have my entity foo which contains the properties id, bar and baz. Can I populate two different tables (like foo1 and foo2) with the same entity, based on the property baz which is not mapped. The code of the entity looks like this :
class foo {
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
*/
private $id;
/**
* @ORM\Column(name="bar", type="string")
*/
private $bar;
/**
* Property not mapped in the database
*/
private $baz;
}
I want if the value of baz is 1, to save the entity in the table foo1, and if the value of baz is 2, to save in the table foo2. Where can I select in which table it would save ?
Use doctrine inheritance:
Doctrine inheritance
It works like this:
BaseClient
Like that you can even add extra fields to let's say SubClient1 or SubClient2 who are specific only for that entity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With