protected function doSave($con) { $affectedRows = 0; if (!$this->alreadyInSave) { $this->alreadyInSave = true; if ($this->aCounselingSpecRelatedByParent !== null) { if ($this->aCounselingSpecRelatedByParent->isModified()) { $affectedRows += $this->aCounselingSpecRelatedByParent->save($con); } $this->setCounselingSpecRelatedByParent($this->aCounselingSpecRelatedByParent); } if ($this->isModified()) { if ($this->isNew()) { $pk = CounselingSpecPeer::doInsert($this, $con); $affectedRows += 1; $this->setId($pk); $this->setNew(false); } else { $affectedRows += CounselingSpecPeer::doUpdate($this, $con); } $this->resetModified(); } if ($this->collCounselingSpecsRelatedByParent !== null) { foreach ($this->collCounselingSpecsRelatedByParent as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collCounselingRaports !== null) { foreach ($this->collCounselingRaports as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }