10.04.2018 Views

Doctrine_manual-1-2-en

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12: YAML Schema Files 196<br />

Listing<br />

12-2<br />

Verbose Syntax<br />

Here is the 100% verbose form of the above schema:<br />

---<br />

User:<br />

columns:<br />

username:<br />

type: string(255)<br />

password:<br />

type: string(255)<br />

contact_id:<br />

type: integer<br />

relations:<br />

Contact:<br />

class: Contact<br />

local: contact_id<br />

foreign: id<br />

foreignAlias: User<br />

foreignType: one<br />

type: one<br />

Contact:<br />

columns:<br />

first_name:<br />

type: string(255)<br />

last_name:<br />

type: string(255)<br />

phone:<br />

type: string(255)<br />

email:<br />

type: string(255)<br />

address:<br />

type: string(255)<br />

relations:<br />

User:<br />

class: User<br />

local: id<br />

foreign: contact_id<br />

foreignAlias: Contact<br />

foreignType: one<br />

type: one<br />

In the above example we do not define the detect_relations option, instead we <strong>manual</strong>ly<br />

define the relationships so we have complete control over the configuration of the local/<br />

foreign key, type and alias of the relationship on each side.<br />

Relationships<br />

Wh<strong>en</strong> specifying relationships it is only necessary to specify the relationship on the <strong>en</strong>d<br />

where the foreign key exists. Wh<strong>en</strong> the schema file is parsed, it reflects the relationship and<br />

builds the opposite <strong>en</strong>d automatically. If you specify the other <strong>en</strong>d of the relationship<br />

<strong>manual</strong>ly, the auto g<strong>en</strong>eration will have no effect.<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!