I am getting a single record response with php script below
<?php
header('Content-Type: application/json');
include "db.php";
$uid = 1;
$stmt = $db->prepare("SELECT * FROM transaction WHERE isAdmin = ?");
$stmt->execute([$uid]);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(
[
'status' =>'success',
'message' => $result,
]);
I get a response of
{
"status": "success",
"message": [
{
"s_n": "1",
"email": "seeme@mail.com",
"info": "Good morning",
"isAdmin": "1"
}
]
}
But I want a response of
{
"status": "success",
"message":
{
"s_n": "1",
"email": "seeme@mail.com",
"info": "Good morning",
"isAdmin": "1"
}
}
How can I get the object response, instead of the array object response?