/** * Returns a new ChildFitEntryTypeQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildFitEntryTypeQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildFitEntryTypeQuery) { return $criteria; } $query = new ChildFitEntryTypeQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Performs an INSERT on the database, given a FitEntryType or Criteria object. * * @param mixed $criteria Criteria or FitEntryType object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(FitEntryTypeTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from FitEntryType object } if ($criteria->containsKey(FitEntryTypeTableMap::COL_ID) && $criteria->keyContainsValue(FitEntryTypeTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . FitEntryTypeTableMap::COL_ID . ')'); } // Set the correct dbName $query = FitEntryTypeQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use($con, $query) { return $query->doInsert($con); }); }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @throws LogicException if no primary key is defined * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = ChildFitEntryTypeQuery::create(); $criteria->add(FitEntryTypeTableMap::COL_ID, $this->id); return $criteria; }
protected function performSave($data, $fork) { $fitEntryType = array(); $fitEntryTypes1 = ECP\FitEntryTypeQuery::create()->find(); foreach ($fitEntryTypes1 as $fitEntryType1) { $fitEntryType[$fitEntryType1->getName()] = $fitEntryType1->getId(); } $entity = $this->getLocalyMappedEntityToSave($data, $fork); $connection = $this->getPropelConnection(); try { $connection->beginTransaction(); $entity->setRulesetEntityId($data->ruleset->id); foreach ($data->content as $dataRow) { $compositionRow = $this->getSubentity($entity, 'CompositionRow', $dataRow); $compositionRow->setShipId($dataRow->shipId); $compositionRow->setNotes(property_exists($dataRow, 'notes') ? $dataRow->notes : ''); $dataFitContent = $dataRow->fit->content; $compositionRow->setFitName($dataFitContent->header->shipName); $fitEntries = $compositionRow->getFitEntries(); $fitEntryIndex = 0; foreach ($dataFitContent->body as $dataFitEntry) { $fitEntryExists = count($fitEntries) > $fitEntryIndex; $fitEntry = null; if ($fitEntryExists) { $fitEntry = $fitEntries[$fitEntryIndex]; } else { $fitEntry = new ECP\FitEntry(); $fitEntry->setInd3x($fitEntryIndex); } $fitEntry->setFitEntryTypeId($fitEntryType[property_exists($dataFitEntry, 'type') ? $dataFitEntry->type : 'none']); $fitEntry->setItemId(property_exists($dataFitEntry, 'item') ? $dataFitEntry->item : 0); $fitEntry->setAmmoId(property_exists($dataFitEntry, 'ammo') ? $dataFitEntry->ammo : 0); $fitEntry->setAmount(property_exists($dataFitEntry, 'amount') ? $dataFitEntry->amount : 0); $this->prepareSubentitySave2($connection, $compositionRow, 'FitEntry', $fitEntry, !$fitEntryExists); $fitEntryIndex++; } for (; $fitEntryIndex < count($fitEntries); $fitEntryIndex++) { $compositionRow->removeFitEntry($fitEntries[$fitEntryIndex]); } $this->prepareSubentitySave($connection, $entity, 'CompositionRow', $compositionRow, $dataRow); } $this->cleanupOldEnties($entity, 'CompositionRow', $data->content); $this->saveGroupAccess($connection, $entity, $data); $entity->save($connection); $connection->commit(); return $this->createIdObj($entity->getId()); } catch (Exception $e) { $connection->rollBack(); throw $e; } }
/** * Get the associated ChildFitEntryType object * * @param ConnectionInterface $con Optional Connection object. * @return ChildFitEntryType The associated ChildFitEntryType object. * @throws PropelException */ public function getFitEntryType(ConnectionInterface $con = null) { if ($this->aFitEntryType === null && $this->fitentrytypeid !== null) { $this->aFitEntryType = ChildFitEntryTypeQuery::create()->findPk($this->fitentrytypeid, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aFitEntryType->addFitEntries($this); */ } return $this->aFitEntryType; }