12345678910111213141516171819202122232425262728 |
- <?php
- require "connectionDb.php";
- $customers = $db->query("SELECT * FROM customer");
- // $customers = $db->query("SELECT * FROM customer LEFT JOIN vehicle ON customer.id=vehicle.customer_id");
- $json_data=[];
- while ($row = $customers->fetchArray()) {
- //print_r($row);
- $details = [
- "Customer_Id" => $row['id'],
- "Name" => $row['name'],
- "Credit_Sale" => ($row['credit_sale']==1)?"Yes":"No",
- //"Id" => $row['id'],
- //"Number" => $row['number'],
- ];
- //here pushing the values in to an array
- array_push($json_data,$details);
- }
- $json_data_all = ["data" => $json_data];
- $myfile = fopen("api/v1/Customers/customers.txt", "w+") or die("Unable to open file!");;
- fwrite($myfile,json_encode($json_data_all, JSON_PRETTY_PRINT));
- fclose($myfile);
- ?>
|