php - Possible OneToOne Doctrine Entity Mapping? -
php - Possible OneToOne Doctrine Entity Mapping? -
i'm forced work fixed database schema, , wondering if possible. 2 tables, , hopeful create unidirectional onetoone mapping. simplified:
/** * @orm\entity * @orm\table(name="superheroes") */ class superhero { /** * @var int * @orm\id * @orm\generatedvalue(strategy="auto") * @orm\column(type="integer", nullable=false, options={"unsigned"=true}) */ protected $id; /** * @var string * @orm\column(type="string", length=64, nullable=false) */ protected $name; }
and ultimate, personal, only-they-can-use weapons:
/** * @orm\entity * @orm\table(name="superhero_weapons") * */ class weapon { /** * @var int * @orm\id * @orm\column(type="integer", nullable=false, options={"unsigned"=true}) */ protected $superhero_id; /** * @var string * @orm\column(type="text", nullable=false) */ protected $name; }
i hopeful finagle call:
$superhero->getweapon();
is possible without adding weapon_id index superhero table? e.g., create like:
* @orm\onetoone(targetentity="weapon")
work in superhero class
the examples @ http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html don't seem identify kind of mapped-the-other-way situation. blind or daft!
thanks!
php doctrine2 zend-framework2
Comments
Post a Comment