function processTableWithTableDDL($table) { global $loadYAMLGeneratorConfig; if ($loadYAMLGeneratorConfig) { $cfg = loadGeneratorConfig($table); if (empty($cfg)) { return false; } if (checkGeneratorConfig($cfg) === false) { return false; } } else { $cfg = null; } if (!$table->primaryKey) { fprintf(STDERR, "Table %s has no primary key.\n", $table->tableName); return false; } $pkColIdx = -1; if (count($table->primaryKey->columns) == 1) { if (($pkColIdx = $table->getColumnIdx($table->primaryKey->columns[0]->name)) >= 0) { if (!in_array($table->columns[$pkColIdx]->type, array('integer', 'smallint', 'bigint'))) { $pkColIdx = -1; } } } if ($pkColIdx < 0) { fprintf(STDERR, "Table %s primary key is incompatible or is not configured.\nThe primary key must be a single column of type integer, smallint or bigint.\n", $table->tableName); return false; } return processTable($table, $table->columns[$pkColIdx]->name, $cfg); }
$sqlA = array(); foreach ($row as $key => $value) { if (!is_numeric($key) && $key != 'id') { if ($value != '') { if ($value = reformatData($value)) { $sqlA[] = array('field' => $key, 'value' => $value); } } } } if ($db->update($table, $sqlA, 'id', $row['id'])) { print $table . ' updated!'; } } } function reformatData($input) { //read into array from Utils::parseConfig $tA = Utils::parseConfig($input); $r = '<config>' . "\n"; foreach ($tA as $key => $value) { $r .= "\t" . '<' . $key . '>' . $value . '</' . $key . '>' . "\n"; } $r .= '</config>'; return $r; } $q = $db->query("\n\tSELECT \n\tid,edit_config,process_config,validate,filter \n\tFROM \n\tcms_cols \n\tWHERE \n\t\t(edit_config != '' ||\n\t\tprocess_config != '' ||\n\t\tvalidate != '' ||\n\t\tfilter != '')\n\tORDER BY id"); processTable($q, 'cms_cols'); $q = $db->query("\n\tSELECT \n\tid,config \n\tFROM \n\tcms_relations \n\tWHERE \n\t\t(config != '') \n\tORDER BY id"); processTable($q, 'cms_relations');