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 20: Database Abstraction Layer 302<br />

[type] => Array<br />

(<br />

[0] => string<br />

)<br />

)<br />

[l<strong>en</strong>gth] => 255<br />

[unsigned] =><br />

[fixed] =><br />

Getting Native Declaration<br />

Listing<br />

20-30<br />

// test.php<br />

Listing<br />

20-31<br />

// ...<br />

$portableDeclaration = array(<br />

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

'l<strong>en</strong>gth' => 20,<br />

'fixed' => true<br />

);<br />

$nativeDeclaration =<br />

$conn->dataDict->getNativeDeclaration($portableDeclaration);<br />

echo $nativeDeclaration;<br />

The above example would output the following:<br />

$ php test.php<br />

CHAR(20)<br />

Drivers<br />

Mysql<br />

Setting table type<br />

Listing<br />

20-32<br />

// test.php<br />

// ...<br />

$fields = array(<br />

'id' => array(<br />

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

'autoincrem<strong>en</strong>t' => true<br />

),<br />

'name' => array(<br />

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

'fixed' => true,<br />

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

)<br />

);<br />

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

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

Saved successfully!

Ooh no, something went wrong!