我尝试将两个表连接在一起,然后使用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().'}';
}
});
暂无答案!
目前还没有任何答案,快来回答吧!