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 31: Real World Examples 379<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('board_id', 'integer', 10);<br />

$this->hasColumn('updated', 'integer', 10);<br />

$this->hasColumn('closed', 'integer', 1);<br />

}<br />

public function setUp()<br />

{<br />

$this->hasOne('Forum_Board as Board', array(<br />

'local' => 'board_id',<br />

'foreign' => 'id'<br />

)<br />

);<br />

}<br />

}<br />

$this->hasMany('Forum_Entry as Entries', array(<br />

'local' => 'id',<br />

'foreign' => thread_id'<br />

)<br />

);<br />

Here is the same example in YAML format. You can read more about YAML in the YAML<br />

Schema Files (page 195) chapter:<br />

---<br />

Forum_Category:<br />

columns:<br />

root_category_id: integer(10)<br />

par<strong>en</strong>t_category_id: integer(10)<br />

name: string(50)<br />

description: string(99999)<br />

relations:<br />

Subcategory:<br />

class: Forum_Category<br />

local: par<strong>en</strong>t_category_id<br />

foreign: id<br />

Rootcategory:<br />

class: Forum_Category<br />

local: root_category_id<br />

foreign: id<br />

Listing<br />

31-4<br />

Forum_Board:<br />

columns:<br />

category_id: integer(10)<br />

name: string(100)<br />

description: string(5000)<br />

relations:<br />

Category:<br />

class: Forum_Category<br />

local: category_id<br />

foreign: id<br />

Threads:<br />

class: Forum_Thread<br />

local: id<br />

foreign: board_id<br />

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

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

Saved successfully!

Ooh no, something went wrong!