src/Model/Adapter/Mysqli/MysqliAsync.php
private function wait()
    {
        do {
            if (empty($this->queries)) {
                break;
            }
            $links = $errors = $reject = [];
            foreach ($this->queries as $link) {
                $links[] = $errors[] = $reject[] = $link['l'];
            }
            if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
                continue;
            }
            foreach ($this->queries as $l => $link) {
                $promise = $this->getPromise($link);
                $cnx    = $this->getConnection($link);
                try {
                    $result = $cnx->reap_async_query();
                    if ($result instanceof mysqli_result) {
                        $promise->resolve($result);
                    } else {
                        $errNo = mysqli_errno($cnx);
                        $errStr = mysqli_error($cnx);
                        if (0 !== $errNo || 0 !== strlen($errStr)) {
                            throw new mysqli_sql_exception($errStr, $errNo);
                        } else {
                            $promise->resolve($cnx);
                        }
                    }
                } catch (mysqli_sql_exception $e) {
                    $promise->reject($e);
                }
                $this->processed++;
                unset($this->queries[$l]);
            }
        } while ($this->processed < count($this->queries));
        $this->reset();
    }
private function wait()
    {
        do {
            if (empty($this->queries)) {
                break;
            }
            $links = $errors = $reject = [];
            foreach ($this->queries as $link) {
                $links[] = $errors[] = $reject[] = $link['l'];
            }
            if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) {
                continue;
            }
            foreach ($this->queries as $l => $link) {
                $promise = $this->getPromise($link);
                $cnx    = $this->getConnection($link);
                try {
                    $result = $cnx->reap_async_query();
                    if ($result instanceof mysqli_result) {
                        $promise->resolve($result);
                    } else {
                        $errNo = mysqli_errno($cnx);
                        $errStr = mysqli_error($cnx);
                        if (0 !== $errNo || 0 !== strlen($errStr)) {
                            throw new mysqli_sql_exception($errStr, $errNo);
                        } else {
                            $promise->resolve($cnx);
                        }
                    }
                } catch (mysqli_sql_exception $e) {
                    $promise->reject($e);
                }
                $this->processed++;
                unset($this->queries[$l]);
            }
        } while ($this->processed < count($this->queries));
        $this->reset();
    }
private function wait ( ) { do { if ( empty ( $ this -> queries ) ) { break ; } $ links = $ errors = $ reject = [ ] ; foreach ( $ this -> queries as $ link ) { $ links [ ] = $ errors [ ] = $ reject [ ] = $ link [ 'l' ] ; } if ( ! mysqli_poll ( $ links , $ errors , $ reject , self :: $ sleep , self :: $ usleep ) ) { continue ; } foreach ( $ this -> queries as $ l => $ link ) { $ promise = $ this -> getPromise ( $ link ) ; $ cnx = $ this -> getConnection ( $ link ) ; try { $ result = $ cnx -> reap_async_query ( ) ; if ( $ result instanceof mysqli_result ) { $ promise -> resolve ( $ result ) ; } else { $ errNo = mysqli_errno ( $ cnx ) ; $ errStr = mysqli_error ( $ cnx ) ; if ( 0 !== $ errNo || 0 !== strlen ( $ errStr ) ) { throw new mysqli_sql_exception ( $ errStr , $ errNo ) ; } else { $ promise -> resolve ( $ cnx ) ; } } } catch ( mysqli_sql_exception $ e ) { $ promise -> reject ( $ e ) ; } $ this -> processed ++ ; unset ( $ this -> queries [ $ l ] ) ; } } while ( $ this -> processed < count ( $ this -> queries ) ) ; $ this -> reset ( ) ; }
Wait for pending queries to complete.
Wait for pending queries to complete .