1
0
mirror of synced 2025-01-18 06:21:40 +03:00

More docs for the usage of indexes

This commit is contained in:
zYne 2007-01-25 12:34:03 +00:00
parent 93977272ca
commit 07cbafe799
3 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,70 @@
<?php ?>
You can add indexes by simple calling Doctrine_Record::option('index', $definition) where $definition is the
definition array. The structure of the definition array is as follows:
<div class='sql'>
<pre>
[ indexName1 => [col1 => [col1-options], ... , colN => [colN-options]
indexName2 => ...
indexNameN => ]
</pre>
</div>
<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');
}
public function setUp()
{
\$this->option('index', array('myindex' => 'name'));
}
}
?>");
?>
<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');
}
public function setUp()
{
\$this->option('index', array('myindex' => array('name', 'code')));
}
}
?>");
?>
<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');
}
public function setUp()
{
\$this->option('index',
array('myindex' => array('name', 'code')
'ageindex' => 'age')
);
}
}
?>");
?>

View File

@ -0,0 +1,20 @@
<?php ?>
Doctrine offers many index options, some of them being db-specific. Here is a full list of availible options:
<div class='sql'>
<pre>
unique => boolean(true / false)
whether or not the index is unique index
sorting => string('ASC' / 'DESC')
what kind of sorting does the index use (ascending / descending)
primary => boolean(true / false)
whether or not the index is primary index
fulltext => boolean(true / false)
whether or not the specified index is a FULLTEXT index (only availible on Mysql)
gist => boolean(true / false)
whether or not the specified index is a GiST index (only availible on Pgsql)
</pre>
</div>

View File

@ -0,0 +1,22 @@
<?php ?>
Doctrine supports many special indexes. These include Mysql FULLTEXT and Pgsql GiST indexes.
In the following example we define a Mysql FULLTEXT index for the field 'content'.
<br \><br \>
<?php
renderCode("<?php
class Article
{
public function setTableDefinition()
{
\$this->hasColumn('name', 'string');
\$this->hasColumn('content', 'string');
}
public function setUp()
{
\$this->option('index',
array('content' =>
array('content' =>
array('fulltext' => true));
}
}
?>");