AsyncMysqlClient::connectWithOpts

Begin an async connection to a MySQL instance

Description

public static function connectWithOpts(
  string $host,
  int $port,
  string $dbname,
  string $user,
  string $password,
  AsyncMysqlConnectionOptions $conn_opts,
): Awaitable<AsyncMysqlConnection>

Use this to asynchronously connect to a MySQL instance.

Normally you would use this to make one asynchronous connection to the MySQL client.

If you want to be able to pool up a bunch of connections, you would call setPoolsConnectionLimit(), create a default pool of connections with AsyncMysqlConnectionPool()::__construct(), which now has that limit set, and then call AsyncMysqlConnectionPool()::connect().

Parameters

  • $host - The hostname to connect to.
  • $port - The port to connect to.
  • $dbname - The initial database to use when connecting.
  • $user - The user to connect as.
  • $password - The password to connect with.
  • AsyncMysqlConnectionOptions $conn_opts

Return Values