Skip to content

Instantly share code, notes, and snippets.

@perrywky
Created September 5, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perrywky/3632682 to your computer and use it in GitHub Desktop.
Save perrywky/3632682 to your computer and use it in GitHub Desktop.
修改ucenter用户名字段长度限制
<?php
//ucenter 1.6.0版本
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';
$dbname = '';
$prefix = 'uc_';
$length = 30;
$link = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db($dbname, $link)){
die('error: ' . mysql_error());
};
$fields = array(
array('admins', 'username', 'char'),
array('badwords', 'admin', 'varchar'),
array('feeds', 'username', 'varchar'),
array('members', 'username', 'char'),
array('mergemembers', 'username', 'char'),
array('protectedmembers', 'username', 'char'),
array('protectedmembers', 'admin', 'char'),
);
foreach($fields as $field){
list($table, $column, $type) = $field;
echo "updating $prefix$table\n";
if(!mysql_query("ALTER TABLE `$prefix$table` CHANGE `$column` `$column` $type( {$length} ) NOT NULL DEFAULT '' ", $link)){
die("error: $table " . mysql_error());
}
}
echo "done\n";
mysql_close($link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment