More docs for the usage of indexes
This commit is contained in:
parent
93977272ca
commit
07cbafe799
70
manual/docs/Getting started - Indexes - Adding indexes.php
Normal file
70
manual/docs/Getting started - Indexes - Adding indexes.php
Normal 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')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>");
|
||||||
|
?>
|
20
manual/docs/Getting started - Indexes - Index options.php
Normal file
20
manual/docs/Getting started - Indexes - Index options.php
Normal 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>
|
22
manual/docs/Getting started - Indexes - Special indexes.php
Normal file
22
manual/docs/Getting started - Indexes - Special indexes.php
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>");
|
Loading…
x
Reference in New Issue
Block a user