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 19: Data Fixtures 287<br />

class ResourceType ext<strong>en</strong>ds <strong>Doctrine</strong>_Record<br />

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('name', 'string', 255);<br />

}<br />

}<br />

public function setUp()<br />

{<br />

$this->hasMany('Resource as Resouces', array(<br />

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

'foreign' => 'resource_type_id'<br />

)<br />

);<br />

}<br />

// models/Tag.php<br />

class Tag ext<strong>en</strong>ds <strong>Doctrine</strong>_Record<br />

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('name', 'string', 255);<br />

}<br />

}<br />

public function setUp()<br />

{<br />

$this->hasMany('Resource as Resources', array(<br />

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

'foreign' => 'resource_id',<br />

'refClass' => 'ResourceTag'<br />

)<br />

);<br />

}<br />

// models/ResourceTag.php<br />

class ResourceTag ext<strong>en</strong>ds <strong>Doctrine</strong>_Record<br />

{<br />

public function setTableDefinition()<br />

{<br />

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

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

}<br />

}<br />

// models/Category.php<br />

class BaseCategory ext<strong>en</strong>ds <strong>Doctrine</strong>_Record<br />

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('name', 'string', 255, array(<br />

'type' => 'string',<br />

'l<strong>en</strong>gth' => '255'<br />

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

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

Saved successfully!

Ooh no, something went wrong!