Somehow the following php code returns 2 JSONs objects instead of 1 object. anyone can see the reason?
the output present the same row duplicated: - first: all the row values - second: (that I need), all the row values + extra sql values
note: already tried mysql_fetch_assoc, it return only the row values
$query = "
select u.*,
COALESCE((SELECT count(t.production)
FROM Transcriptions t
where t.ACCOUNT_ID = u.ACCOUNT_ID
and t.production = 1
group by u.ACCOUNT_ID
),0) as transcriptions_count
from users u";
$result = mysql_query($query, $connection);
while ($row = mysql_fetch_array($result))
{
$objects[] = $row;
}
echo json_encode($objects);
output:
[{"0":"10463","PID":"10463"},{"PID":"10463","transcriptions_count":"158"}]
output should return:
[{"PID":"10463","transcriptions_count":"158"}]
Comments
Post a Comment