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 58<br />

}<br />

}<br />

$this->hasColumn('floattest', 'float');<br />

Listing<br />

7-14<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 />

Test:<br />

columns:<br />

floattest: float<br />

Decimal<br />

The decimal data type may store fixed precision decimal numbers. This data type is suitable<br />

for repres<strong>en</strong>ting numbers that require high precision and accuracy.<br />

Listing<br />

7-15<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('decimaltest', 'decimal');<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 />

Listing<br />

7-16<br />

---<br />

Test:<br />

columns:<br />

decimaltest: decimal<br />

You can specify the l<strong>en</strong>gth of the decimal just like you would set the l<strong>en</strong>gth of any other<br />

column and you can specify the scale as an option in the third argum<strong>en</strong>t:<br />

Listing<br />

7-17<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('decimaltest', 'decimal', 18, array(<br />

'scale' => 2<br />

)<br />

);<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 />

Listing<br />

7-18<br />

---<br />

Test:<br />

columns:<br />

decimaltest:<br />

type: decimal(18)<br />

scale: 2<br />

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

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

Saved successfully!

Ooh no, something went wrong!