/** * Returns a new ChildLockQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildLockQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildLockQuery) { return $criteria; } $query = new ChildLockQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Performs an INSERT on the database, given a Lock or Criteria object. * * @param mixed $criteria Criteria or Lock 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(LockTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Lock object } // Set the correct dbName $query = LockQuery::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); }); }
/** * Delete the lock passing request object * * @param Request $request Request that is used for this delete method, $request->getDataObject(0) will contain * query data to fetch the old object * * @return void */ public function delete(Request $request) { /** @var \Tasker\Mapper\Lock\Entity $mapper */ $mapper = DbMapperFactory::make('lock|entity'); $mapper->setArrays($request->getData()); $dbAttributesForQuery = $mapper->getMappedSecondAttributes(); $lockQuery = new LockQuery(); // Get the old entity /** @var \Propel\Runtime\Collection\ObjectCollection $dbEntities */ $dbEntities = $lockQuery->findByArray($dbAttributesForQuery); /** @var \Tasker\DataGateway\Db\Entity\Lock $dbEntity */ $dbEntities->delete(); // Return empty array that it will indicate a deleted collection to the caller $this->setEntitiesFromResponse([]); }
/** * Removes this object from datastore and sets delete attribute. * * @param ConnectionInterface $con * @return void * @throws PropelException * @see Lock::setDeleted() * @see Lock::isDeleted() */ public function delete(ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection(LockTableMap::DATABASE_NAME); } $con->transaction(function () use($con) { $deleteQuery = ChildLockQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $this->setDeleted(true); } }); }