/** * neue System-Optionen bei Update erzeugen * @return bool */ private function addSystemOptions() { $yatdl = new \fpcm\model\system\yatdl(\fpcm\classes\baseconfig::$dbStructPath . '06config.yml'); $yatdl->parse(); $data = $yatdl->getArray(); if (!isset($data['defaultvalues']['rows']) || !count($data['defaultvalues']['rows'])) { return true; } $res = true; foreach ($data['defaultvalues']['rows'] as $option) { $res = $res && $this->config->add($option['config_name'], $option['config_value']); } return $res; }
/** * Vergleicht die aktuelle Struktur der Tabelle in der DB mit der Struktur der YML-Datei und * fügt ggf. fehlende Spalten zur Tabelle in der DB hinzu * @param string $tableFile * @return boolean * @since FPCM 3.3.2 */ public function checkTableStructure($tableFile) { $isPg = $this->dbtype === 'pgsql' ? true : false; $typeMap = $this->driver->getYaTDLDataTypes(); $yatdl = new \fpcm\model\system\yatdl(baseconfig::$dbStructPath . $tableFile . '.yml'); $data = $yatdl->getArray(); $table = $data['name']; $structure = $this->getTableStructure($table); $lenghtTypes = array('varchar'); if ($isPg) { $lenghtTypes += array('int', 'bigint', 'bool'); } foreach ($data['cols'] as $col => $attr) { if (isset($structure[$col])) { continue; } if (!isset($typeMap[$attr['type']])) { trigger_error('Undefined data type for column ' . $col); continue; } $type = $typeMap[$attr['type']]; if (in_array($attr['type'], $lenghtTypes)) { $length = (int) $attr['length']; $type .= "({$length})"; } if ($isPg) { $attr['params'] = str_replace('NOT NULL', '', $attr['params']); } $type .= trim($attr['params']) ? ' ' . $attr['params'] : ''; if (!$this->alter($table, 'ADD', $col, $type, false)) { logs::sqllogWrite($this->lastQueryString); return false; } } return true; }