Skip to content

Instantly share code, notes, and snippets.

@plankes-projects
Last active April 12, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plankes-projects/d941f49bf74353f0b29700261192c639 to your computer and use it in GitHub Desktop.
Save plankes-projects/d941f49bf74353f0b29700261192c639 to your computer and use it in GitHub Desktop.
query call
$sslOption = null;
if(isset($dbConfig['options'][\PDO::MYSQL_ATTR_SSL_CA])) {
$sslOption = new ClientTlsContext();
$sslOption->withCaFile($dbConfig['options'][\PDO::MYSQL_ATTR_SSL_CA]);
}
$host = $dbConfig['host'];
$port = $dbConfig['port'];
$user = $dbConfig['username'];
$pass = $dbConfig['password'];
$db = $dbConfig['database'];
$timeout = $dbConfig['options'][\PDO::ATTR_TIMEOUT] ?? 30000;
$config = ConnectionConfig::parseConnectionString("host=$host:$port;user=$user;pass=$pass;db=$db", $sslOption)
->withCharset($dbConfig['charset'], $dbConfig['collation']);
$pool = new Pool($config, self::DEFAULT_MAX_CONNECTIONS, new TimeoutConnector($timeout));
$pool->execute(<query>, <params>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment