FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

redoufu/php-async-sql: PHP异步执行多个SQL · GitHub

Repository navigation

About

PHP异步执行多个SQL

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

php-async-sql

PHP使用mysqli相关方法异步执行多个SQL

###require mysql驱动必须是mysqlnd

PHP版本>=5.3

###示例

<?php
include 'AsyncMysqli.class.php';

// 同一个database情况
$dbconf = array(
    'host'     => '127.0.0.1',
    'user'     => 'root',
    'password' => 'liang',
    'database' => 'service',
    'port'     => '3306'
);
$sqlconfs = array(
    's1' => array(
        'sql' => 'select sleep(1) as s1'
    ),
    's2' => array(
        'sql' => 'select sleep(1) as s2'
    )
);
try {
    $async = new \redoufu\AsyncMysqli($dbconf['host'], $dbconf['user'], $dbconf['password'], $dbconf['database'], $dbconf['port']);
    $re = $async->query($sqlconfs);
    var_dump($re);
} catch (\Exception $e) {
    die($e->getMessage() . "\n");
}
die;
// 不同database调用方法:
$sqlconfs = array(
    's1' => array(
        'dbconfig'     => array(
            'host'     => '127.0.0.1',
            'user'     => 'root',
            'password' => 'liang',
            'database' => 'service',
            'port'     => '3306'
        ),
        'sql' => 'select sleep(1) as s1'
    ),
    's2' => array(
        'dbconfig'     => array(
            'host'     => '127.0.0.1',
            'user'     => 'root',
            'password' => 'liang',
            'database' => 'test',
            'port'     => '3306'
        ),
        'sql' => 'select sleep(1) as s2'
    )
);
try {
    $async = new \redoufu\AsyncMysqli();
    $re = $async->query($sqlconfs);
    $async->close();
    var_dump($re);
} catch (\Exception $e) {
    die($e->getMessage() . "\n");
}

About

PHP异步执行多个SQL

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL