public function commentsForResultAction() { $labResultId = (int) $this->_getParam('labResultId'); $noteText = "No comments for this result"; $labNote = new LabNote(); $db = Zend_Registry::get('dbAdapter'); $labSelect = $db->select()->from('lab_note')->join('lab_test', 'lab_test.lab_test_id = lab_note.lab_test_id')->join('lab_result', 'lab_result.lab_test_id = lab_test.lab_test_id')->where('lab_result_id = ?', $labResultId); foreach ($db->query($labSelect)->fetchAll() as $row) { $labNote->labNoteId = $row['lab_note_id']; $labNote->populate(); if (strlen($labNote->note) > 0) { $noteText = $labNote->note; } } //trigger_error($labSelect->__toString(), E_USER_NOTICE); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array($noteText)); }