/** * Adds a new column to a table. * * @param string $tableName A table name. * @param string $columnName A column name. * @param string $type A data type. * @param array $options Column options. See * Horde_Db_Adapter_Base_TableDefinition#column() * for details. */ public function addColumn($tableName, $columnName, $type, $options = array()) { if ($this->transactionStarted()) { throw new Horde_Db_Exception('Cannot add columns to a SQLite database while inside a transaction'); } if ($type == 'autoincrementKey') { $this->_alterTable($tableName, array(), create_function('$definition', sprintf('$definition->column("%s", "%s", %s);', $columnName, $type, var_export($options, true)))); } else { parent::addColumn($tableName, $columnName, $type, $options); } // See last paragraph on http://www.sqlite.org/lang_altertable.html $this->execute('VACUUM'); }
/** * Adds a new column to a table. * * @param string $tableName A table name. * @param string $columnName A column name. * @param string $type A data type. * @param array $options Column options. See * Horde_Db_Adapter_Base_TableDefinition#column() * for details. */ public function addColumn($tableName, $columnName, $type, $options = array()) { /* Ignore ':autoincrement' - it is handled automatically by SQLite * for any 'INTEGER PRIMARY KEY' column. */ if ($this->transactionStarted()) { throw new Horde_Db_Exception('Cannot add columns to a SQLite database while inside a transaction'); } parent::addColumn($tableName, $columnName, $type, $options); // See last paragraph on http://www.sqlite.org/lang_altertable.html $this->execute('VACUUM'); }