Currently with SS3 I am always getting an error when trying to return a datalist as JSON and since we can't debug with isDev=1 due to a core SS bug and no error is being written to log I can't figure out why the following code is erroring out.
$sql = "CALL get_closest_state(".$lat.",".$long.");";
$results = DB::query($sql);
for ($i = 0; $i < $results->numRecords(); $i++) {
$record = $results->nextRecord();
$states[] = $record['State'];
}
$programs = Program::get()->filter(array('StateID' => $states))->toNestedArray();
return json_encode($programs);
Note in the above if I dump out $states it is a proper array with two strings so I know the SP is running fine. Just for some reason any time I try to query my Program dataobject it always fails. If I remove the ->toNestedArray() and view the var I see it is a datalist but when I try to get any data from that datalist it just errors out.
Any help would be great. I have been seeing many issues with the new SS3 data model where it just does not seem to work even through I am following the api documentation.
Thanks in advance,
Joe