Using this example: Basic Many-To-One Mapping <http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#many-to-one-unidirectional>
I am having a hard time connecting these concepts: - concept of a database column that is foreign key -- an integer number (address_id) - concept of an object - or an instance of an object (class Address, new Address()) In the example above they are connected conceptually yet they are definitely *not *the same. I can see that maybe if you begin with Doctrine in mind, that is not much of an issue and you just accept it as given and not question it perhaps. But to give you a further example of why I am bothered by this is this: ... I started out using MySQL way way back. Now I am slowly converting my code to use Doctrine on existing tables. So ie, to use the above example, I would start off having a class that returns an *integer* foreign key, because that is what is already used extensively in my code for a lot of things. i.e.: class User { /** @Column(name="address_id") */ private $addressId; /* * Most of my existing code is written to use the _id - an Integer * So my getters would return that integer */ function getAddressId() { return $this->addressId; } } /* * Sample Usage */ $addressId = $user->getAddressId(); Later when I get around to using more of Doctrine's power of JOINs/etc, I would create Address Entity, then Doctrinify my getters and upgrade my association on the User side as well: class User { /** * @ManyToOne(targetEntity="Address") * @JoinColumn(name="address_id", referencedColumnName="id") */ private $address; /* * Most of my existing code is written to use the _id - an Integer */ function getAddress() { return $this->address; } } /* * Sample New Usage for old code: */ $addressId = $user->getAddress()->getId(); So in this case across my schemas I have a mix of foreign keys that are integers and ones that are Doctrine Entity objects. They are not the same, obviously, so I was curious to see if there is a way to think about them as "same" in some way ... or to not try to understand the connection and just accept it as a paradigm shift. -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+unsubscr...@googlegroups.com. To post to this group, send email to doctrine-user@googlegroups.com. Visit this group at https://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.