/** * Rename field and rebuild the database table * @param string $oldname * @param string $newName * @return boolean */ public function renameField($oldName, $newName) { $fields = $this->getFieldsConfig(); $fields[$newName] = $fields[$oldName]; unset($fields[$oldName]); $this->_config->set('fields', $fields); $indexes = $this->getIndexesConfig(); /** * Check for indexes for field */ foreach ($indexes as $index => &$config) { if (isset($config['columns']) && !empty($config['columns'])) { /* * Rename index link */ foreach ($config['columns'] as $id => &$value) { if ($value === $oldName) { $value = $newName; } } unset($value); } } $this->_config->set('indexes', $indexes); $builder = new Db_Object_Builder($this->getName(), false); return $builder->renameField($oldName, $newName); }