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 7: Defining Models 87<br />

}<br />

{<br />

}<br />

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

$this->index('myindex', array(<br />

'fields' => array('name')<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 />

IndexTest:<br />

columns:<br />

name: string<br />

indexes:<br />

myindex:<br />

fields: [name]<br />

Listing<br />

7-90<br />

An example of adding a multi-column index to field called name:<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

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

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

Listing<br />

7-91<br />

}<br />

}<br />

$this->index('myindex', array(<br />

'fields' => array('name', 'code')<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 />

MultiColumnIndexTest:<br />

columns:<br />

name: string<br />

code: string<br />

indexes:<br />

myindex:<br />

fields: [name, code]<br />

Listing<br />

7-92<br />

An example of adding multiple indexes on same table:<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

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

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

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

Listing<br />

7-93<br />

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

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

Saved successfully!

Ooh no, something went wrong!