Object relational mapping - Table options.php 791 Bytes
Newer Older
1

hansbrix's avatar
hansbrix committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
Doctrine offers various table options. All table options can be set via Doctrine_Record::option($optionName, $value)



For example if you are using Mysql and want to use INNODB tables it can be done as follows:



<code type="php">
class MyInnoDbRecord extends Doctrine_Record
{
    public function setTableDefinition()
    {
        \$this->hasColumn('name', 'string');

        \$this->option('type', 'INNODB');
    }
}
?></code> 


In the following example we set the collate and character set options:



<code type="php">
class MyCustomOptionRecord extends Doctrine_Record
{
    public function setTableDefinition()
    {
        \$this->hasColumn('name', 'string');

        \$this->option('collate', 'utf8_unicode_ci');
        \$this->option('charset', 'utf8');
    }
}
?></code>