Showing posts with label db collation. Show all posts
Showing posts with label db collation. Show all posts

Friday, October 2, 2015

Change Database Collation with PHP

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]

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...