AsyncMysqlConnection::warningCount
The number of errors, warnings, and notes returned during execution of the previous SQL statement
public function warningCount(): int;
Returns
int
- Theint
count of errors, warnings, etc.
Examples
The following example shows how to get the number of errors or warnings on the last SQL query via AsyncMysqlConnection::warningCount
.
require __DIR__.'/../../__includes/async_mysql_connect.inc.php';
use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;
async function connect(
\AsyncMysqlConnectionPool $pool,
): Awaitable<\AsyncMysqlConnection> {
return await $pool->connect(
CI::$host,
CI::$port,
CI::$db,
CI::$user,
CI::$passwd,
);
}
async function get_warning_count_on_query(): Awaitable<int> {
$pool = new \AsyncMysqlConnectionPool(darray[]);
$conn = await connect($pool);
$result = await $conn->query('SELECT name FROM test_table WHERE userID = 1');
$wc = $conn->warningCount();
$conn->close();
return $wc;
}
function run(): void {
$wc = \HH\Asio\join(get_warning_count_on_query());
\var_dump($wc);
}
run();
int(0)