51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
$rootPath = dirname(dirname(__DIR__));
|
|
require_once($rootPath . "/src/config/env.php");
|
|
include_once('../config/connection.php');
|
|
include_once('../config/functions.php');
|
|
$conn = openDatabaseConnection();
|
|
|
|
$stmt = $conn->prepare("SELECT
|
|
c.id,
|
|
c.name,
|
|
c.description,
|
|
c.website,
|
|
c.telephone,
|
|
c.latitude,
|
|
c.longitude,
|
|
c.thumbnail,
|
|
c.country,
|
|
c.province,
|
|
u.first_name,
|
|
u.last_name,
|
|
u.profile_pic
|
|
FROM campsites c
|
|
LEFT JOIN users u ON c.user_id = u.user_id");
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
$campsites = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$campsites[] = [
|
|
'id' => $row['id'],
|
|
'name' => $row['name'],
|
|
'description' => $row['description'],
|
|
'website' => $row['website'],
|
|
'telephone' => $row['telephone'],
|
|
'latitude' => $row['latitude'],
|
|
'longitude' => $row['longitude'],
|
|
'thumbnail' => $row['thumbnail'],
|
|
'country' => $row['country'],
|
|
'province' => $row['province'],
|
|
'user' => [
|
|
'first_name' => $row['first_name'],
|
|
'last_name' => $row['last_name'],
|
|
'profile_pic' => $row['profile_pic']
|
|
]
|
|
];
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($campsites);
|
|
|