I am trying to create json response from a database results, the issue i am having is that, if i request one item i get the result as i need it but i am not receiving the collection with the code below.
The data is there i can see it when i do a var_dump.
Here is the code.
$i = 0;
while ( $obj = sqlsrv_fetch_array ( $stmt3, SQLSRV_FETCH_ASSOC ) ) {
$rows [] = array (
'Note Id' => $obj ['NoteId'],
'Patient Id' => $obj ['PatientID'],
'Note Text' => $obj ['NoteText'],
'Date of Note' => $obj ['DateOfNote'],
'Category Id' => $obj ['CategoryId']
);
$i ++;
}
echo json_encode ( $rows);
Here is an extract from the var_dump
array(27) { [0]=> array(5) { ["Note Id"]=> int(66) ["Patient Id"]=> string(36) "xxxxxxxxxxxxxxxx" ["Note Text"]=> string(70) "Remember to set " ["Date of Note"]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2012-01-30 16:13:04.033000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } ["Category Id"]=> int(1) } [1]=> array(5) { ["Note Id"]=> int(67) ["Patient Id"]=> string(36) "xxxxxxxxxxxxxx" ["Note Text"]=> string(61) "Keep having" ["Date of Note"]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2012-01-30 16:13:52.763000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } ["Category Id"]=> int(1) }