/** * Adds new columns to the new schema * * @return bool */ protected function addColumns() { if (!isset($this->data['new'])) { return true; } $colref = count($this->oldschema->getColumns()) + 1; foreach ($this->data['new'] as $column) { if (!$column['isenabled']) { continue; } // we do not add a disabled column // todo this duplicates the hardcoding as in the function above $newEntry = array(); $newEntry['config'] = $column['config']; $newEntry['label'] = $column['label']; $newEntry['ismulti'] = $column['ismulti']; $newEntry['class'] = $column['class']; $sort = $column['sort']; // only save if the column got a name if (!$newEntry['label']) { continue; } // add new column to the data table if (!$this->addDataTableColumn($colref)) { return false; } // save the type $ok = $this->sqlite->storeEntry('types', $newEntry); if (!$ok) { return false; } $res = $this->sqlite->query('SELECT last_insert_rowid()'); if (!$res) { return false; } $newTid = $this->sqlite->res2single($res); $this->sqlite->res_close($res); // add this type to the schema columns $schemaEntry = array('sid' => $this->newschemaid, 'colref' => $colref, 'enabled' => true, 'tid' => $newTid, 'sort' => $sort); $ok = $this->sqlite->storeEntry('schema_cols', $schemaEntry); if (!$ok) { return false; } $colref++; } return true; }