Beispiel #1
0
 /**
  * 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([]);
 }
Beispiel #2
0
 private function processQueryAndSetEntities($sql)
 {
     $config = Helper::getConfig();
     $tableReference = $config['repository']['tableReference'];
     $search = array_keys($tableReference);
     $replace = array_values($tableReference);
     $sql = str_replace($search, $replace, $sql);
     $pdo = new \PDO($config['database']['dsn'], $config['database']['username'], $config['database']['password']);
     $stmt = $pdo->prepare($sql);
     $stmt->setFetchMode(\PDO::FETCH_ASSOC);
     $stmt->execute();
     $result = $stmt->fetchAll();
     $mapper = DbMapperFactory::make('task|pdo|entity');
     $mapper->setArrays($result);
     $this->setEntitiesFromResponse($mapper->getMappedFirstEntities());
 }