Object relational mapping - Indexes - Index options.php 1.39 KB
Newer Older
1 2 3
<?php ?>
Doctrine offers many index options, some of them being db-specific. Here is a full list of availible options:
<div class='sql'>
zYne's avatar
zYne committed
4
<pre>        
5 6 7 8

sorting     => string('ASC' / 'DESC')      
        what kind of sorting does the index use (ascending / descending)

zYne's avatar
zYne committed
9 10 11
length      => integer
        index length (only some drivers support this)

12 13 14
primary     => boolean(true / false)        
        whether or not the index is primary index

zYne's avatar
zYne committed
15 16 17 18
type        => string('unique',         -- supported by most drivers
                      'fulltext',       -- only availible on Mysql driver
                      'gist',           -- only availible on Pgsql driver
                      'gin')            -- only availible on Pgsql driver
19 20
</pre>
</div>
zYne's avatar
zYne committed
21 22 23 24 25 26 27 28 29
<?php
renderCode("<?php
class MultipleIndexTest extends Doctrine_Record
{
    public function setTableDefinition() 
    {
        \$this->hasColumn('name', 'string');
        \$this->hasColumn('code', 'string');
        \$this->hasColumn('age', 'integer');
zYne's avatar
zYne committed
30

zYne's avatar
zYne committed
31 32 33 34 35 36 37 38 39 40 41 42
        \$this->index('myindex', array(
                      'fields' => array(
                                  'name' =>
                                  array('sorting' => 'ASC',
                                        'length'  => 10),
                                  'code'),
                      'type' => 'unique',
                      ));
    }
}
?>");
?>