Just trying to specify some tables structures and models for Doctrine in a YAML file. I’m going through the documentation on this page: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/yaml-schema-files/en
I haven’t quite got a grasp on what each line in the relations section is doing.
Here’s some sample YAML from that page:
User:
columns:
username:
type: string(255)
password:
type: string(255)
contact_id:
type: integer
relations:
Contact:
class: Contact
local: contact_id
foreign: id
foreignAlias: User
foreignType: one
type: one
Specifically, relations, in order:
Contact is.. I am guessing the name of the other corresponding table pertaining to this relationship?
class: contact is.. what exactly? The name of the model that will be created from this YAML?
local: contact_id is the local key, I understand this.
foreign: id is the field name of the foreign key, I understand this
foreignAlias: User what is this line doing?
foreignType: one
type: one: I am guessing these two lines together specify the type of relationship, eg, one-to-one?
Thanks for any and all help.
Nope. It is the Name of the object you later use when accessing contact information of a user.
$user->Contact->email
This can be different from the Class-Name
That is the class you are referencing. Needs to be the Classname in the YAML (i.e. Contact)
This is the name you can access the user information from a contact object.
$contact->User->username