Guest User

Untitled

a guest
Apr 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $sslOption = null;
  2. if(isset($dbConfig['options'][\PDO::MYSQL_ATTR_SSL_CA])) {
  3. $sslOption = new ClientTlsContext();
  4. $sslOption->withCaFile($dbConfig['options'][\PDO::MYSQL_ATTR_SSL_CA]);
  5. }
  6.  
  7. $host = $dbConfig['host'];
  8. $port = $dbConfig['port'];
  9. $user = $dbConfig['username'];
  10. $pass = $dbConfig['password'];
  11. $db = $dbConfig['database'];
  12. $timeout = $dbConfig['options'][\PDO::ATTR_TIMEOUT] ?? 30000;
  13.  
  14. $config = ConnectionConfig::parseConnectionString("host=$host:$port;user=$user;pass=$pass;db=$db", $sslOption)
  15. ->withCharset($dbConfig['charset'], $dbConfig['collation']);
  16. $pool = new Pool($config, self::DEFAULT_MAX_CONNECTIONS, new TimeoutConnector($timeout));
  17.  
  18. $pool->execute(<query>, <params>);
Add Comment
Please, Sign In to add comment