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