\n",$s) . "
\n";
}
/* ------- cutomize here --------- */
$conn = mysql_connect("", "", "") or die ("Impossible to connect");
mysql_select_db ("") or die ("Impossible to connect");
$t_prefix = "";
/* end of customization */
mysql_query("SET NAMES 'utf8'");
$collation_src = "latin1_swedish_ci";
$collation_dest = "utf8_general_ci";
$charset_dest = "utf8";
$result = "";
/* get all tables in db*/
$req = "Show tables";
$sqlresult = mysql_query($req,$conn);
if (! $sqlresult )
{
$result .= "problem SQL : " . $req . " / " . mysql_error();
}
else
{
/* loop on tables */
while ($table = mysql_fetch_array($sqlresult, MYSQL_NUM))
{
$tablename=$table[0];
/* if it is a PWG table */
if (substr($tablename,0,strlen($t_prefix)) == $t_prefix)
{
$result .= "Checking " . $tablename . "...\n";
$req = "SHOW FULL COLUMNS FROM " . $tablename;
$sqlresultcol = mysql_query($req,$conn);
if (! $sqlresultcol )
{
$result .= "problème SQL : " . $req . " / " . mysql_error();
}
else
{
/* loop on table columns */
while ($column = mysql_fetch_array($sqlresultcol, MYSQL_ASSOC))
{
if (substr($column['Collation'],0,strlen($collation_src)) == $collation_src)
{
$req = 'ALTER TABLE ' . $tablename . " CHANGE " . $column['Field'] . " " . $column['Field'] . " " . $column['Type'] . " CHARACTER SET " . $charset_dest . " COLLATE " . $collation_dest ;
if ($column['Default'] != "")
{
$req .= " DEFAULT '" . $column['Default'] . "'";
}
$sqlresultchange = mysql_query($req,$conn);
if (! $sqlresultchange )
{
$result .= "problème SQL : " . $req . " / " . mysql_error() . "\n";
}
else
{
$result .= $tablename . "." . $column['Field'] . " modifiées\n";
}
}
}
}
}
}
}
tohtml( $result) ;
?>