public function ajaxListAddressesAction() { $patientId = (int) $this->_getParam('patientId'); $rows = array(); $db = Zend_Registry::get('dbAdapter'); $sqlSelect = $db->select()->from('address')->where('person_id = ?', $patientId); $addressIterator = new AddressIterator(); $addressIterator->setDbSelect($sqlSelect); foreach ($addressIterator as $addr) { $tmp = array(); $tmp['id'] = $addr->address_id; $tmp['data'][] = $addr->name; $tmp['data'][] = $addr->type; $tmp['data'][] = $addr->line1; $tmp['data'][] = $addr->line2; $tmp['data'][] = $addr->city; //$tmp['data'][] = $addr->region; $tmp['data'][] = $addr->state; $tmp['data'][] = $addr->postal_code; $tmp['data'][] = $addr->notes; $tmp['data'][] = $addr->active; $rows[] = $tmp; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
public function ajaxListAddressesAction() { $personId = (int) $this->_getParam('personId'); $rows = array(); $db = Zend_Registry::get('dbAdapter'); $sqlSelect = $db->select()->from('address')->where('person_id = ?', $personId); $addressIterator = new AddressIterator(); $addressIterator->setDbSelect($sqlSelect); foreach ($addressIterator as $addr) { $rows[] = $this->_toJSON($addr, 'addressId', array('name', 'type', 'line1', 'line2', 'city', 'state', 'postal_code', 'notes', 'active')); } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }