1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/manual/docs/Object relational mapping - Indexes - Adding indexes.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2007-01-25 15:34:03 +03:00
<?php ?>
2007-02-11 14:13:37 +03:00
You can add indexes by simple calling Doctrine_Record::index('indexName', $definition) where $definition is the
definition array.
2007-01-25 15:34:03 +03:00
<br \><br \>
An example of adding a simple index to field called 'name':
<br \><br \>
<?php
renderCode("<?php
class IndexTest extends Doctrine_Record
{
public function setTableDefinition()
{
\$this->hasColumn('name', 'string');
2007-03-21 01:53:23 +03:00
2007-02-11 14:13:37 +03:00
\$this->index('myindex', array('fields' => 'name');
2007-01-25 15:34:03 +03:00
}
}
?>");
?>
<br \><br \>
An example of adding a multi-column index to field called 'name':
<br \><br \>
<?php
renderCode("<?php
class MultiColumnIndexTest extends Doctrine_Record
{
public function setTableDefinition()
{
\$this->hasColumn('name', 'string');
\$this->hasColumn('code', 'string');
2007-03-21 01:53:23 +03:00
2007-02-11 14:13:37 +03:00
\$this->index('myindex', array('fields' => array('name', 'code')));
2007-01-25 15:34:03 +03:00
}
}
?>");
?>
<br \><br \>
An example of adding a multiple indexes on same table:
<br \><br \>
<?php
renderCode("<?php
class MultipleIndexTest extends Doctrine_Record
{
public function setTableDefinition()
{
\$this->hasColumn('name', 'string');
\$this->hasColumn('code', 'string');
\$this->hasColumn('age', 'integer');
2007-03-21 01:53:23 +03:00
2007-02-11 14:13:37 +03:00
\$this->index('myindex', array('fields' => array('name', 'code')));
\$this->index('ageindex', array('fields' => array('age'));
2007-01-25 15:34:03 +03:00
}
}
?>");
?>