function genTable(\Amp\Mysql\Pool $db) { (yield $db->query("CREATE TABLE tmp SELECT 1 AS a, 2 AS b")); $promises = []; foreach (range(1, 5) as $num) { $promises[] = $db->query("INSERT INTO tmp (a, b) VALUES ({$num}, {$num} * 2)"); } (yield \Amp\all($promises)); }
/** This should throw an exception as the password is incorrect. */ function testWrongPassword() { $this->setExpectedException("Exception"); (new NativeReactor())->run(function ($reactor) { $db = new Pool("host=" . DB_HOST . ";user="******";pass=the_wrong_password;db=connectiontest", null, $reactor); /* Try a query */ (yield $db->query("CREATE TABLE tmp SELECT 1 AS a, 2 AS b")); }); }