Example #1
0
 public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Connection) {
         // parse sql
         $parser = $this->templateFactory->newSqlParser();
         $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql'));
         $connection->executeUpdate($sql, $parser->getSqlParameters());
         return $this->response->build(200, [], array('success' => true, 'message' => 'Execution was successful'));
     } else {
         throw new ConfigurationException('Given connection must be an DBAL connection');
     }
 }
Example #2
0
 public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Connection) {
         // parse sql
         $parser = $this->templateFactory->newSqlParser();
         $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql'));
         $result = $connection->fetchAll($sql, $parser->getSqlParameters());
         $key = $configuration->get('propertyName') ?: 'entry';
         return $this->response->build(200, [], [$key => CurveArray::nest($result)]);
     } else {
         throw new ConfigurationException('Given connection must be a DBAL connection');
     }
 }
Example #3
0
 public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
 {
     $connection = $this->connector->getConnection($configuration->get('connection'));
     if ($connection instanceof Connection) {
         // parse sql
         $parser = $this->templateFactory->newSqlParser();
         $sql = $parser->parse($request, $context->withConnection($connection), $configuration->get('sql'));
         $result = $connection->fetchAssoc($sql, $parser->getSqlParameters());
         if (empty($result)) {
             throw new StatusCode\NotFoundException('Entry not available');
         }
         return $this->response->build(200, [], CurveArray::nest($result));
     } else {
         throw new ConfigurationException('Given connection must be an DBAL connection');
     }
 }