Commit 0b3a3c38 authored by zYne's avatar zYne

Index support added!

parent cced9028
......@@ -1538,7 +1538,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public function index($name, array $definition = array())
{
if ( ! $columns) {
if ( ! $definition) {
return $this->_table->getIndex($name);
} else {
return $this->_table->addIndex($name, $definition);
......
......@@ -136,13 +136,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* -- inheritanceMap inheritanceMap is used for inheritance mapping, keys representing columns and values
* the column values that should correspond to child classes
*
* -- engine database engine (mysql example: INNODB)
* -- type table type (mysql example: INNODB)
*
* -- charset character set
*
* -- collation
*
* -- index the index definitions of this table
* -- indexes the index definitions of this table
*
* -- treeImpl the tree implementation of this table (if any)
*
......@@ -158,7 +158,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
'collation' => null,
'treeImpl' => null,
'treeOptions' => null,
'index' => array(),
'indexes' => array(),
);
/**
* @var Doctrine_Tree $tree tree object associated with this table
......@@ -412,6 +412,31 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return isset($this->options[$option]);
}
/**
* addIndex
*
* adds an index to this table
*
* @return void
*/
public function addIndex($index, array $definition)
{
$index = $this->conn->getIndexName($index);
$this->options['indexes'][$index] = $definition;
}
/**
* getIndex
*
* @return array|boolean array on success, FALSE on failure
*/
public function getIndex($index)
{
if (isset($this->options['indexes'][$index])) {
return $this->options['indexes'][$index];
}
return false;
}
/**
* createQuery
* creates a new Doctrine_Query object and adds the component name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment