const express = require('express');
const { connectToDatabase } = require('../utils/connectDb');

const router = express.Router();

router.get("/branche.php", async (req,res)=>{
    const connection = await connectToDatabase();
    connection.query("SELECT * FROM webapp_phabranche", undefined, (error, results) => {
      if (error) {
        res.send(error)
      } else {
        res.send(results)
      }
    });
  });
  router.get("/brancherel.php", async (req,res)=>{
    const connection = await connectToDatabase();
    connection.query("SELECT * FROM webapp_phabrancherel", undefined, (error, results) => {
      if (error) {
        res.send(error)
      } else {
        res.send(results)
      }
    });
  });
  router.get("/name.php", async (req,res)=>{
    const connection = await connectToDatabase();
    connection.query("SELECT * FROM webapp_pharmacies", undefined, (error, results) => {
      if (error) {
        res.send(error)
      } else {
        res.send(results)
      }
    });
  });
  router.get("/number.php", async (req,res)=>{
    const connection = await connectToDatabase();
    connection.query("SELECT * FROM webapp_phanumber", undefined, (error, results) => {
      if (error) {
        res.send(error)
      } else {
        res.send(results)
      }
    });
  });
  router.get("/relation.php", async (req,res)=>{
    const connection = await connectToDatabase();
    connection.query("SELECT * FROM webapp_phanumber", undefined, (error, results) => {
      if (error) {
        res.send(error)
      } else {
        res.send(results)
      }
    });
  });

module.exports = router;