コード例 #1
0
ファイル: SqlExecute.php プロジェクト: uqiauto/fusio
 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');
     }
 }
コード例 #2
0
ファイル: SqlFetchAll.php プロジェクト: uqiauto/fusio
 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');
     }
 }
コード例 #3
0
ファイル: SqlFetchRow.php プロジェクト: uqiauto/fusio
 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');
     }
 }