Amp\Mysql\Pool::init PHP Method

init() public method

public init ( )
    public function init()
    {
        return $this->connectionPool->getConnectionPromise();
    }

Usage Example

示例#1
0
 function testConnect()
 {
     $complete = false;
     (new NativeReactor())->run(function ($reactor) use(&$complete) {
         $db = new Pool("host=" . DB_HOST . ";user="******";pass="******";db=connectiontest", null, $reactor);
         (yield $db->init());
         // force waiting for connection
         /* use an alternative charset... Default is utf8mb4_general_ci */
         $db->setCharset("latin1_general_ci");
         $complete = true;
     });
     $this->assertEquals(true, $complete, "Database commands did not complete.");
 }