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

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('booltest', 'boolean');<br />

}<br />

}<br />

Listing<br />

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

booltest: boolean<br />

Listing<br />

7-10<br />

Integer<br />

The integer type is the same as integer type in PHP. It may store integer values as large as<br />

each DBMS may handle.<br />

Fields of this type may be created optionally as unsigned integers but not all DBMS support<br />

it. Therefore, such option may be ignored. Truly portable applications should not rely on the<br />

availability of this option.<br />

The integer type maps to differ<strong>en</strong>t database type dep<strong>en</strong>ding on the column l<strong>en</strong>gth.<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('integertest', 'integer', 4, array(<br />

'unsigned' => true<br />

)<br />

);<br />

}<br />

}<br />

Listing<br />

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

integertest:<br />

type: integer(4)<br />

unsigned: true<br />

Listing<br />

7-12<br />

Float<br />

The float data type may store floating point decimal numbers. This data type is suitable for<br />

repres<strong>en</strong>ting numbers withina large scale range that do not require high accuracy. The scale<br />

and the precision limits of the values that may be stored in a database dep<strong>en</strong>ds on the DBMS<br />

that it is used.<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

Listing<br />

7-13<br />

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

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

Saved successfully!

Ooh no, something went wrong!