Ok, I've got another wiki merging with us - we use a global user
table, they don't. We need to merge their entries in their user
table, into our global user table - our solution was to take our
highest user number so far (402) and add it to every UID in the user
table, then go through each table and do the same for every place a
UID appeared. I am VERY MUCH a PHP newbie - I am pretty dang good at
hacking mediawiki to make it do what I want, but when it comes to
writing code from scratch, well, I know nothing.
So, this is my first attempt at a script - of course it doesn't work,
I have absolutely no idea what I'm doing, just went through some
mediawiki, mint, and phpBB code and pulled out bits that looked
relevant and threw them together. Could somebody either try to fix
this, or write a quick script to go through a mySQL table and add a
number (402) to every entry in a given column?
<?php
$success = false;
$db = array(
'server' => 'localhost',
'username' => '<snip>',
'password' => '<snip>',
'database' => '<snip>',
'tblPrefix' => 'wiki_',
'tblName' => 'archive',
'connected' => 0
);
$targetAdd = 420;
$save = array();
function query($setrowname,$setrowdata,$whererowname,$whererowdata) {
$thisresult = mysql_query(
"UPDATE `{$this->db['tblPrefix']}{$this->db['tblName']}` SET
`
{$setrowname}` = '{$setrowdata}' WHERE `{$whererowname}`=
{$whererowdata}"
);
return $thisresult;
}
if ( @mysql_connect($this->db['server'],$this->db['username'],$this-
db['password']) ) {
if (
@mysql_select_db($this->db['database']) ) {
$thisresult = mysql_query( "SELECT * FROM `{$this->db['tblPrefix']}
{$this->db['tblName']}` ORDER BY `id` ASC LIMIT $start, $limit" );
$row = mysql_fetch_assoc($thisresult);
}
}
foreach($row as $column => $value) {
if( $column == 'user_id' ) {
$oldUID = $value;
$save[$oldUID] = $value + $targetAdd;
query('user_id',$save[$oldUID],'user_id',$oldUID);
}
}
return $success
?>