This little sql statement can change the collation in your database including tables, columns and everywhere. This is something phpMyAdmin can not handle completely.
Credits goes to original poster.
[sourcecode language="php"]
$conn1=new MySQLi("localhost","root","","exam_db");
if($conn1->connect_errno){
echo mysqli_connect_error();
exit;
}
$res=$conn1->query("show tables") or die($conn1->error);
while($tables=$res->fetch_array()){
$conn1->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die($conn1->error);
}
echo "The collation of your database has been successfully changed!";
$res->free();
$conn1->close();
[/sourcecode]
No comments:
Post a Comment