laravel import , export database
Hi
I'm using laravel 6 with wamp on a Windows server.
I use multiple databases and I want to know if it's possible to export database (as zip or else) with a button on my site ?
For example, my end user connect to the right DB, hit export button and save DB in my computer into a json file like postman.
Someone has an idea ?
Thanks
Following code should work. But exporting database as sql is the preferred way.
$sql = "select ...";
$db = new PDO ( "mysql:$dbname", $user, $password) ;
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll();
file_put_contents("output.txt", json_encode($result));
Please or to participate in this conversation.