public function saveJosTeaching(JosTeaching $jos_teaching) { $data = array('subject_id' => $jos_teaching->getSubjectId(), 'user_id' => $jos_teaching->getUserId(), 'lesson_number' => $jos_teaching->getLessonNumber(), 'qualifications' => $jos_teaching->getQualifications(), 'edu_system' => $jos_teaching->getEduSystem(), 'note' => $jos_teaching->getNote()); $value_id = (int) $jos_teaching->getValueId(); if ($value_id == 0) { $this->tableGateway->insert($data); } else { if ($this->getTeachingByArrayConditionAndArrayColumns(array('value_id' => $value_id), array('user_id'))) { $this->tableGateway->update($data, array('value_id' => $value_id)); } else { return false; } } return true; }