PHP code example of irap / async-query

1. Go to this page and download the library: Download irap/async-query library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

irap / async-query example snippets


# Create the connection pool
$connectionPool = new \iRAP\AsyncQuery\MysqliConnectionPool(
    5, # max connections
    DB_HOST,
    DB_USER,
    DB_PASSWORD,
    DB_NAME
);

$sql =  "SHOW TABLES";

$queryCallback = function($result) {
    if ($result === FALSE)
    {
        throw new Exception("query failed!");
    }
};

$asyncQuery = new \iRAP\AsyncQuery\AsyncQuery(
    $sql,
    $queryCallback,
    $connectionPool
);

# Execute the query and wait for its result
while ($asyncQuery->run() === FALSE)
{
    usleep(1);
}