'id', 'fields'=>array('name', 'comment', 'keywords')); $arr['tblDocumentFiles'] = array('key'=>'id', 'fields'=>array('name', 'comment', 'mimeType')); $arr['tblFolders'] = array('key'=>'id', 'fields'=>array('name', 'comment')); $arr['tblUsers'] = array('key'=>'id', 'fields'=>array('fullName', 'comment')); $arr['tblGroups'] = array('key'=>'id', 'fields'=>array('name', 'comment')); $arr['tblKeywords'] = array('key'=>'id', 'fields'=>array('keywords')); $arr['tblKeywordCategories'] = array('key'=>'id', 'fields'=>array('name')); $arr['tblCategory'] = array('key'=>'id', 'fields'=>array('name')); $arr['tblEvents'] = array('key'=>'id', 'fields'=>array('name', 'comment')); $arr['tblDocumentApproveLog'] = array('key'=>'approveLogId', 'fields'=>array('comment')); $arr['tblDocumentStatusLog'] = array('key'=>'statusLogId', 'fields'=>array('comment')); $arr['tblDocumentReviewLog'] = array('key'=>'reviewLogId', 'fields'=>array('comment')); $arr['tblDocumentContent'] = array('keys'=>array('document', 'version'), 'fields'=>array('comment', 'mimeType')); $allupdates = array(); echo "\n"; echo "\n"; foreach($arr as $tblname => $schema) { if(isset($schema['key'])) $queryStr = "SELECT ".$schema['key'].", `".implode('`,`', $schema['fields'])."` FROM ".$tblname; elseif(isset($schema['keys'])) $queryStr = "SELECT ".implode(',', $schema['keys']).", `".implode('`,`', $schema['fields'])."` FROM ".$tblname; $res = $db->query($queryStr); $recs = $res->fetchAll(PDO::FETCH_ASSOC); foreach($recs as $rec) { foreach($schema['fields'] as $field) { if($rec[$field] !== mydmsDecodeString($rec[$field])) { $updateSql = "UPDATE ".$tblname." SET `".$field."`=".$db->quote(mydmsDecodeString($rec[$field]))." where "; if(isset($schema['key'])) $updateSql .= $schema['key']."=".$rec[$schema['key']]; elseif(isset($schema['keys'])) { $where = array(); foreach($schema['keys'] as $key) { $where[] = $key."=".$rec[$key]; } $updateSql .= implode(' AND ', $where); } $allupdates[] = $updateSql; echo "\n"; if($doupdate) { $res = $db->exec($updateSql); if(!$res) { $errormsg = 'Could not execute update statement'; echo "\n"; } else { $errormsg = 'Object updated'; echo "\n"; } } } } } } echo "
TableFieldOld ValueNew ValueUpdate statement
".$tblname."".$field."".htmlspecialchars($rec[$field])."".htmlspecialchars(mydmsDecodeString($rec[$field]))."
".htmlspecialchars($updateSql)."
".$errormsg."
".$errormsg."
\n"; if($allupdates) { echo "Summary of all updates
\n"; echo "
".implode("
", $allupdates)."
"; } return true; } /* }}} */ if(isset($_GET['doupdate']) && $_GET['doupdate'] == 1) $doupdate = 1; else $doupdate = 0; $doupdate = 1; if (!check($doupdate)) { print "

Update failed

"; } if(!$doupdate) { print "

If the above update statements look ok, either execute them in your prefered mysql client or click on the link below.

"; print "Execute update
\n"; } ?>