query() public method

public query ( $query )
コード例 #1
0
ファイル: generic_table.php プロジェクト: amphp/mysql
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));
}
コード例 #2
0
ファイル: PoolTest.php プロジェクト: sagara-/mysql
 /** 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"));
     });
 }