<?php 
    require "connectionDb.php";

$suppliers = $db->query("SELECT * FROM user");

$json_data=[];

while ($row = $suppliers->fetchArray()) {
    //print_r($row);
$details = [
"Id" => $row['id'],
"Name" => $row['name'],
"Email" => $row['email'],
"Password" => $row['password'],
"Activation_Token" => $row['activation_token'],
"Password_Reset_Token" => $row['password_reset_token'],
"Join_Token" => $row['join_token'],
"Role" => $row['role'],
"Pass_Code" => $row['pass_code'],
"Pump_List" => $row['pump_list'],
];
//here pushing the values in to an array  
array_push($json_data,$details);  
}
$json_data_all = ["data" => $json_data];

$myfile = fopen("api/v1/Users/users.txt", "w+") or die("Unable to open file!");;
fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
fclose($myfile);
 ?>