Hi doctrine 2 lovers,
As I promised in my previous post, here I came with my very next post, which is the relationship mapping using Doctrine 2. Before going any further make sure that you have read my previous post, which is about table mapping using Doctrine 2. And I assume you have at least a little bit of knowledge about using Doctrine 2 YAML syntaxes and indentation, which is also highlighted in my previous post. Ok, enough about my previous post, now let’s get back to the today’s topic 🙂
As you know, or will know in a moment, there are two major types of relationships between tables. Which are,
And with above two types, the relationship could be,
In this post I will be discussing on all eight combinations starting on Unidirectional/Bidirectional relationship types of one-to-one.
I hope you are doing good 🙂 Recently, I have been working on a Symfony 2 project and in Symfony 2, the data layer is managed by using Doctrine ORM. So today, I planned to post an article on how to correctly map an existing data table using Doctrine 2.x object relationship mapping (ORM) techniques. Later, (in next post) I will be showing how to map a relationship such as one-to-one, one-to-many, many-to-one, unidirectional and bidirectional using the same Doctrine ORM techniques.
Before continuing the Doctrine mapping procedure, we need a pre built table. This table can be any database format. For the sake of easiness I will be using a very simple MySQL data table. The name of the table is ‘user’ and table looks like this,
||primary key, auto increment, not null