From 04337d7531e6d048a24d4a9ffe93ff60f3e68e2a Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 16 Jan 2005 13:49:30 +0000 Subject: [PATCH] A little utility script to perform search and replace on the whole database. It's not linked from anywhere yet. I'm not sure if this will work on PostgreSQL ... can someone test that? --- admin/replace.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 admin/replace.php diff --git a/admin/replace.php b/admin/replace.php new file mode 100644 index 0000000000..33d9c8d65d --- /dev/null +++ b/admin/replace.php @@ -0,0 +1,58 @@ +'; + echo '
'; + echo ''; + echo 'Search whole database for:
'; + echo 'Replace with this string:

'; + echo '
'; + echo '
'; + echo ''; + print_simple_box_end(); + die; +} + + +if (!$tables = $db->Metatables() ) { // No tables yet at all. + error("no tables"); +} + +print_simple_box_start('center'); +foreach ($tables as $table) { + if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these + continue; + } + if ($columns = $db->MetaColumns($table, false)) { + foreach ($columns as $column => $data) { + if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only + $db->debug = true; + execute_sql("UPDATE {$CFG->prefix}$table SET $column = REPLACE($column, '$search', '$replace');"); + $db->debug = false; + } + } + } +} +print_simple_box_end(); + +print_continue('index.php'); + +?> -- 2.39.5