Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Last active April 25, 2020 09:45
Show Gist options
  • Save jaytaph/020be951edb7952c9357d35bd47633d4 to your computer and use it in GitHub Desktop.
Save jaytaph/020be951edb7952c9357d35bd47633d4 to your computer and use it in GitHub Desktop.
namespace KeyRotate;
use Doctrine\Common\Cache\PhpFileCache;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
class PdoMysql extends Driver
{
protected $client;
protected $cache;
/**
* Cannot add a constructor with params, since it's called in DBAL's drivermanager like:
* $className = $params['driverClass'] ?? self::$_driverMap[$params['driver']];
* $driver = new $className();
*/
function __construct($client, $cache) {
}
}
<?php
use Doctrine\DBAL\DriverManager;
$connectionParams = [
'dbname' => 'mysql',
'user' => '/secret/database-2',
'password' => '', //fetched from
'host' => 'mijn.rds.eu-west-1.rds.amazonaws.com',
'driverClass' => KeyRotate\PdoMysql::class,
];
$conn = DriverManager::getConnection($connectionParams);
while (true) {
sleep(1);
$result = $conn->query("SELECT 1")->execute();
print_r($result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment