PHP code example of fiber-interop / mysqli

1. Go to this page and download the library: Download fiber-interop/mysqli 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/ */

    

fiber-interop / mysqli example snippets


use function fiber\{run, go, await_all};

$rows = run(fn() => await_all(array_map(
    fn($sql) => go(function () use ($sql) {
        $m = new mysqli('127.0.0.1', 'app', 'secret', 'shop');   // one connection per concurrent query
        return fiber\mysqli\query($m, $sql)->fetch_all();        // same contract as $m->query()
    }),
    ['SELECT * FROM orders', 'SELECT * FROM customers'],
)));