/** * Save an entity * * @param BaseEntityAbstract $entity The entity that we are tyring to save * * @return GenericDAO */ public function save(BaseEntityAbstract $entity) { if (is_array($messages = $entity->validateAll()) && count($messages) > 0) { throw new EntityValidationException($messages); } $newEntity = trim($entity->getId()) === ''; $entity = Dao::save($entity); if ($newEntity === true) { $this->_lastId = $entity->getId(); $this->_affectedRows = 1; } else { $this->_affectedRows = 1; $this->_lastId = -1; } $this->resetQuery(); return $entity; }