Adds an index key

@param *string $name   Name of key
@param *array  $fields List of key fields

@return Eden\Mysql\Create
968439
public function addKey($name, array $fields)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $this->keys[$name] = $fields;
        return $this;
    }
917977
public function addUniqueKey($columns, $name = null)
    {
        return $this->addKey(new Key(Key::TYPE_UNIQUE, (array) $columns, $name));
    }
759288
public function field($name) {
        $this->_fields['' . $name . ''] = new Field($name, $this->_name);

        return $this->_fields['' . $name . ''];
    }
796315
public function createIndex($name, $columns, $unique=false)
    {
        if (!is_array($columns)) {
            $columns = array($columns);
        }
        foreach ($columns as &$column) {
            $column = $this->_database->prepareIdentifier($column);
        }
        $this->_database->exec(
            sprintf(
                'CREATE %s INDEX %s ON %s (%s)',
                $unique ? 'UNIQUE' : '',
                $this->_database->prepareIdentifier($name),
                $this->_database->prepareIdentifier($this->_name),
                implode(', ', $columns)
            )
        );
        // Reset index cache to force re-read by next getIndexes() invokation
        $this->_indexes = array();
    }
909442
public function addName($name)
    {
        if (!in_array('names', $this->setFields)) {
            $this->setFields[] = 'names';
        }
        $this->names[] = $name;

        return $this;
    }
525960
public function addFields($fields)
    {
        foreach ($fields as $field) {
            if (is_array($field)) {
                $this->addField(...$field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
422914
public function addFields(array $fields)
    {
        foreach ($fields as $field)
        {
            $name = $field->getName();
            $addFields[$name] = $field; # we key by name to prevent duplicates!
        }
        
        $keysString = "";
        $fieldStrings = array();
        
        foreach ($addFields as $fieldName => $field)
        {
            $fieldStrings[] = $field->getFieldString();
                
            /* @var $field DatabaseField */
            if ($field->isPrimaryKey())
            {
                $errMsg = 'Do not set field to be primary key when adding fields. ' .
                          'Instead, use the changePrimaryKey method';
                throw new \Exception($errMsg);
            }
            elseif ($field->isKey())
            {
                if ($keysString !== "")
                {
                    $keysString .= ", ";
                }
                
                if ($field->isUnique())
                {
                    $keysString .= "UNIQUE ";
                }
                
                $keysString .= "KEY (`" . $fieldName . "`) ";
            }
        }
        
        $fieldsString = implode(", ", $fieldStrings);
        
        $fieldsString .= $keysString;
        
        $query = 
            "ALTER TABLE " . 
            "`" . $this->m_name . "` " . 
            "ADD " .
            "(" . $fieldsString . ") ";
        
        $result = $this->m_mysqliConn->query($query);
        
        if ($result !== TRUE)
        {
            throw new \Exception('Error creating table with query: ' . $query);
        }
    }
855338
public function addIndex($name, $attrs)
    {
        if (is_string($attrs)) {
            $attrs = ['type' => $attrs];
        }
        $attrs = array_intersect_key($attrs, static::$_indexKeys);
        $attrs += static::$_indexKeys;
        unset($attrs['references'], $attrs['update'], $attrs['delete']);

        if (!in_array($attrs['type'], static::$_validIndexTypes, true)) {
            throw new Exception(sprintf('Invalid index type "%s" in index "%s" in table "%s".', $attrs['type'], $name, $this->_table));
        }
        if (empty($attrs['columns'])) {
            throw new Exception(sprintf('Index "%s" in table "%s" must have at least one column.', $name, $this->_table));
        }
        $attrs['columns'] = (array)$attrs['columns'];
        foreach ($attrs['columns'] as $field) {
            if (empty($this->_columns[$field])) {
                $msg = sprintf(
                    'Columns used in index "%s" in table "%s" must be added to the Table schema first. ' .
                    'The column "%s" was not found.',
                    $name,
                    $this->_table,
                    $field
                );
                throw new Exception($msg);
            }
        }
        $this->_indexes[$name] = $attrs;

        return $this;
    }
72736
public function add($name)
    {
        if (isset($this->indexes[$name])) {
            return $this->indexes[$name];
        }
        $this->context->getMappings();
        $index = count($this->names);
        $this->names[] = $name;
        $this->indexes[$name] = $index;
        return $index;
    }
1149088
public function addForeignKey($name, $table, $key)
    {
        $this->keys[$name] = [$table, $key];
        return $this;
    }
1250497
public function addField($key, $value)
    {
        $fields       = $this->_queryBuilder->getFields() ? $this->_queryBuilder->getFields() : array();
        $fields[$key] = $value;
        $this->setFields($fields);
        return $this;
    }
954177
public function select($fields = [])
    {
        if (is_array($fields)) {
            foreach ($fields as $field) {
                $this->addSelect($field);
            }
        } elseif (is_string($fields)) {
            $this->addSelect($fields);
        }

        return $this;
    }
56567
public function fillKeyField(array &$fields)
    {
        $model   = $this->config->getDataModel();
        $keyName = $model->getKeyName();

        //add the primary key field, which will be uneditable, but part of the data model
        if ($this->config->getType() === 'model' && !isset($fields[$keyName])) {
            $keyField         = $this->make($keyName, array('visible' => false));
            $fields[$keyName] = $keyField->getOptions();
        }
    }
928991
public function add(array $fields)
    {
        foreach ($fields as $field => $normalizer) {
            if (is_array($normalizer)) {
                // 'field' => ['field.path', 'defaultValue']
                if (2 == count($normalizer)) {
                    $this->path($field, $normalizer[ 0 ], $normalizer[ 1 ]);
                } else {
                    throw new GenericException('Array can contain only 2 elements!');
                }
            } // 'field' => '::method'
            elseif (0 === strpos($normalizer, '::')) {
                $method = str_replace('::', '', $normalizer);
                if (is_int($field)) {
                    $field = $method;
                }
                $this->method($field, $method);
            } // 'field' => 'field.path'
            else {
                $this->path($field, $normalizer);
            }
        }

        return $this;
    }
1336397
public function addForeignKey($name, $table, $key)
    {
        $this->addKeys[$name] = [$table, $key];
        return $this;
    }
790468
public function addField($name, $attrs)
    {
        if (is_string($attrs)) {
            $attrs = ['type' => $attrs];
        }
        $attrs = array_intersect_key($attrs, $this->_fieldDefaults);
        $this->_fields[$name] = $attrs + $this->_fieldDefaults;

        return $this;
    }
648081
public function insertFieldAfter($name, Element\AbstractElement $field)
    {
        foreach ($this->fields as $i => $group) {
            $fields = [];
            foreach ($group as $key => $value) {
                if ($key == $name) {
                    $fields[$key] = $value;
                    $fields[$field->getName()] = $field;
                } else {
                    $fields[$key] = $value;
                }
            }
            $this->fields[$i] = $fields;
        }
        return $this;
    }