0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHPで AWS Aurora Serverless の Data API を利用してみた

Last updated at Posted at 2021-03-04

前提条件

AWS SDK for PHP 3.x を利用
Data API の有効化など完了しているとする

やってみた感想

可もなく不可もなく

RDSDataServiceClientを利用して結果を取得する

sample.php
<?php

use Aws\Exception\AwsException;
use Aws\RDSDataService\RDSDataServiceClient;

try {
    $client = new RDSDataServiceClient([
        'region'  => 'ap-northeast-1',
        'version' => 'latest',
        'credentials' => [
            'key'    => '****',
            'secret' => '****',
        ],
    ]);

    $result = $client->executeStatement([
        'secretArn'   => 'arn:aws:secretsmanager:ap-northeast-1:****:secret:****',
        'resourceArn' => 'arn:aws:rds:ap-northeast-1:****:cluster:****',
        'sql'         => 'SELECT * FROM hoge',
    ]);

    var_dump($result->get('records'));
} catch (AwsException $e) {
    echo $e->getAwsErrorMessage();
}

参考

Aurora Serverless の Data API の使用
Class RDSDataServiceClient

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?