public function update(C3op_Register_Linkage $i) { if (!isset($this->identityMap[$i])) { throw new C3op_Register_LinkageMapperException('Object has no ID, cannot update.'); } $sql = sprintf('UPDATE register_linkages SET contact = %d, institution = %d, department = \'%s\', state = \'%s\', position = \'%s\' WHERE id = %d;', $i->GetContact(), $i->GetInstitution(), $i->GetDepartment(), $i->GetState(), $i->GetPosition(), $this->identityMap[$i]); try { $this->db->exec($sql); } catch (Exception $e) { throw new C3op_Register_LinkageException("{$sql} failed"); } }
public function process($data) { if ($this->isValid($data) !== true) { throw new C3op_Form_LinkageCreateException('Invalid data!'); } else { $db = Zend_Registry::get('db'); $linkageMapper = new C3op_Register_LinkageMapper($db); $linkage = new C3op_Register_Linkage(); $linkage->SetDepartment($this->department->GetValue()); $linkage->SetPosition($this->position->GetValue()); // $linkage->SetState($this->state->GetValue()); $linkage->SetContact($this->contact->GetValue()); $institution = $this->institution->GetValue(); $linkage->SetInstitution($institution); $linkageMapper->insert($linkage); } }