/**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      ConnectionInterface $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see save()
  */
 protected function doSave(ConnectionInterface $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aКалендарьRelatedByдатавыдачи !== null) {
             if ($this->aКалендарьRelatedByдатавыдачи->isModified() || $this->aКалендарьRelatedByдатавыдачи->isNew()) {
                 $affectedRows += $this->aКалендарьRelatedByдатавыдачи->save($con);
             }
             $this->setКалендарьRelatedByдатавыдачи($this->aКалендарьRelatedByдатавыдачи);
         }
         if ($this->aКонтролирующиеОрганы !== null) {
             if ($this->aКонтролирующиеОрганы->isModified() || $this->aКонтролирующиеОрганы->isNew()) {
                 $affectedRows += $this->aКонтролирующиеОрганы->save($con);
             }
             $this->setКонтролирующиеОрганы($this->aКонтролирующиеОрганы);
         }
         if ($this->aКалендарьRelatedByплановаядатаустранения !== null) {
             if ($this->aКалендарьRelatedByплановаядатаустранения->isModified() || $this->aКалендарьRelatedByплановаядатаустранения->isNew()) {
                 $affectedRows += $this->aКалендарьRelatedByплановаядатаустранения->save($con);
             }
             $this->setКалендарьRelatedByплановаядатаустранения($this->aКалендарьRelatedByплановаядатаустранения);
         }
         if ($this->aПодрядчикиПредписания !== null) {
             if ($this->aПодрядчикиПредписания->isModified() || $this->aПодрядчикиПредписания->isNew()) {
                 $affectedRows += $this->aПодрядчикиПредписания->save($con);
             }
             $this->setПодрядчикиПредписания($this->aПодрядчикиПредписания);
         }
         if ($this->aПроекты !== null) {
             if ($this->aПроекты->isModified() || $this->aПроекты->isNew()) {
                 $affectedRows += $this->aПроекты->save($con);
             }
             $this->setПроекты($this->aПроекты);
         }
         if ($this->aСтатусыЗаявкиЗавершение !== null) {
             if ($this->aСтатусыЗаявкиЗавершение->isModified() || $this->aСтатусыЗаявкиЗавершение->isNew()) {
                 $affectedRows += $this->aСтатусыЗаявкиЗавершение->save($con);
             }
             $this->setСтатусыЗаявкиЗавершение($this->aСтатусыЗаявкиЗавершение);
         }
         if ($this->aСтатусыЗаявкиПросрочка !== null) {
             if ($this->aСтатусыЗаявкиПросрочка->isModified() || $this->aСтатусыЗаявкиПросрочка->isNew()) {
                 $affectedRows += $this->aСтатусыЗаявкиПросрочка->save($con);
             }
             $this->setСтатусыЗаявкиПросрочка($this->aСтатусыЗаявкиПросрочка);
         }
         if ($this->aТипыЗамечаний !== null) {
             if ($this->aТипыЗамечаний->isModified() || $this->aТипыЗамечаний->isNew()) {
                 $affectedRows += $this->aТипыЗамечаний->save($con);
             }
             $this->setТипыЗамечаний($this->aТипыЗамечаний);
         }
         if ($this->aКалендарьRelatedByфактическаядатаустранения !== null) {
             if ($this->aКалендарьRelatedByфактическаядатаустранения->isModified() || $this->aКалендарьRelatedByфактическаядатаустранения->isNew()) {
                 $affectedRows += $this->aКалендарьRelatedByфактическаядатаустранения->save($con);
             }
             $this->setКалендарьRelatedByфактическаядатаустранения($this->aКалендарьRelatedByфактическаядатаустранения);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }