Last active
April 25, 2020 09:45
-
-
Save jaytaph/020be951edb7952c9357d35bd47633d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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