10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: Defining Models 59<br />

String<br />

The text data type is available with two options for the l<strong>en</strong>gth: one that is explicitly l<strong>en</strong>gth<br />

limited and another of undefined l<strong>en</strong>gth that should be as large as the database allows.<br />

The l<strong>en</strong>gth limited option is the most recomm<strong>en</strong>ded for effici<strong>en</strong>cy reasons. The undefined<br />

l<strong>en</strong>gth option allows very large fields but may prev<strong>en</strong>t the use of indexes, nullability and may<br />

not allow sorting on fields of its type.<br />

The fields of this type should be able to handle 8 bit characters. Drivers take care of DBMS<br />

specific escaping of characters of special meaning with the values of the strings to be<br />

converted to this type.<br />

By default <strong>Doctrine</strong> will use variable l<strong>en</strong>gth character types. If fixed l<strong>en</strong>gth types should be<br />

used can be controlled via the fixed modifier.<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('stringtest', 'string', 200, array(<br />

'fixed' => true<br />

)<br />

);<br />

}<br />

}<br />

Listing<br />

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

stringtest:<br />

type: string(200)<br />

fixed: true<br />

Listing<br />

7-20<br />

Array<br />

This is the same as the 'array' type in PHP.<br />

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

{<br />

public function setTableDefinition()<br />

{<br />

$this->hasColumn('arraytest', 'array', 10000);<br />

}<br />

}<br />

Listing<br />

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

arraytest: array(10000)<br />

Listing<br />

7-22<br />

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

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

Saved successfully!

Ooh no, something went wrong!