Exemplo n.º 1
0
 public function testExecute()
 {
     try {
         $async_mysql = new \Jenner\Mysql\Async();
         $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port' => 3306], 'select ID,NAME from async');
         $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port' => 3306], 'select ID,NAME from async');
         $result = $async_mysql->execute(true);
         $sync_result = $temp_result = array();
         $mysql = mysqli_connect('127.0.0.1', 'root', '', 'test', 3306);
         $temp = $mysql->query("select ID,NAME from async");
         while (($row = $temp->fetch_assoc()) && ($temp_result[] = $row)) {
         }
         $sync_result[] = $temp_result;
         $temp_result = array();
         $temp = $mysql->query("select ID,NAME from async");
         while (($row = $temp->fetch_assoc()) && ($temp_result[] = $row)) {
         }
         $sync_result[] = $temp_result;
         $this->assertEquals($result, $sync_result);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Jenner
 * Date: 2015/7/20
 * Time: 17:40
 */
require dirname(dirname(__FILE__)) . '/vendor/autoload.php';
try {
    $async_mysql = new \Jenner\Mysql\Async();
    $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test'], 'select * from stu');
    $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test'], 'select * from stu limit 0, 3');
    $result = $async_mysql->execute();
    print_r($result);
} catch (Exception $e) {
    echo $e->getMessage();
}
<?php

/**
 * Created by PhpStorm.
 * User: Jenner
 * Date: 2015/7/23
 * Time: 9:37
 */
require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$timer = new \Jenner\Timer(\Jenner\Timer::UNIT_KB);
$timer->mark("start");
for ($i = 0; $i < 10; $i++) {
    try {
        $async_mysql = new \Jenner\Mysql\Async();
        $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port' => 3306], 'select ID, NAME from async');
        $async_mysql->attach(['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port' => 3306], 'select ID, NAME from async');
        $result = $async_mysql->execute();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
$timer->mark("stop");
$timer->printDiffReport();