From: Aaron Schulz Date: Thu, 25 Dec 2008 04:31:44 +0000 (+0000) Subject: Add a little script I use to change db prefix X-Git-Tag: 1.31.0-rc.0~43787 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=d86b78dadf9ba8607c1c6d7b817b59d4fa0a06a2;p=lhc%2Fweb%2Fwiklou.git Add a little script I use to change db prefix --- diff --git a/maintenance/renameDbPrefix.php b/maintenance/renameDbPrefix.php new file mode 100644 index 0000000000..17568b4a04 --- /dev/null +++ b/maintenance/renameDbPrefix.php @@ -0,0 +1,68 @@ +query( "SHOW TABLES LIKE '".$dbw->escapeLike($old)."%'" ); +foreach( $res as $row ) { + // XXX: odd syntax. MySQL outputs an oddly cased "Tables of X" + // sort of message. Best not to try $row->x stuff... + $fields = get_object_vars( $row ); + // Silly for loop over one field... + foreach( $fields as $resName => $table ) { + // $old should be regexp safe ([a-zA-Z_]) + $newTable = preg_replace( '/^'.$old.'/',$new,$table); + print "Renaming table $table to $newTable\n"; + $dbw->query( "RENAME TABLE $table TO $newTable" ); + } + $count++; +} +print "Done! [$count tables]\n"; +