我正在尝试将两个表连接在一起,然后使用API来检索JSON格式的数据。
当我加入PHPMyAdmin中的表时,它工作正常但是当我在我的PHP代码中使用完全相同的SQL语句并使用Postman来测试它时,没有返回任何内容。
请帮忙,
非常感谢,
PHP CODE:
$app->get('/api/getbooking', function(Request $request, Response $response){
session_id('TEST'); // NEED TO FIND A WAY TO CARRY SESSIONS OVER SUBDOMAINS - ASSIGNING THE ID IS BAD!
session_start();
//$sql = "Select * from login where username ='{$_SESSION['Username']}'";
$sql= "SELECT *
FROM booking
INNER JOIN artistlocation ON booking.ArtistID = artistlocation.ArtistID
WHERE CustomerID = 13";
try{
$db = new db();
$db = $db->connect();
$stmt = $db->query($sql);
$customers = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
echo json_encode($customers);
//This whole block of code needs improving
}
catch(PDOException $e){
echo '{"error": {"text": '.$e->getMessage().'}';
}
});