Beispiel #1
0
 public function statement($sql, $params = null)
 {
     $command = new Command($sql, $params);
     $deferred = new Deferred();
     $this->pool->withConnection(function (Connection $connection) use($command, $deferred) {
         $sql = $command->getPreparedQuery($connection);
         $connection->query($sql, MYSQLI_ASYNC);
         $this->conns[$connection->id] = ['mysqli' => $connection, 'deferred' => $deferred];
     });
     return $deferred->promise();
 }
 /**
  * TODO: This test is still todo.
  *
  * @throws \Exception
  */
 public function testParamCounting()
 {
     // Note: Used a comma rather than => so it was failing.
     // param count would detect this sooner.
     // Intentionally bad parameters to ensure check.
     $badParams = [':test', 1];
     // The programmer's intent was:
     // $goodParams = [ ':test' => 1, ]
     $command = new Command('SELECT * FROM simple_table WHERE id = :test', $badParams);
     $connection = ConnectionFactory::createConnection();
     $query = $command->getPreparedQuery($connection);
     // TODO: Here is the bad result, :test should have been 1
     // TODO: GetPreparedQuery should error on param mismatch
     $this->assertStringEqualsIgnoreSpacing('SELECT * FROM simple_table WHERE id = :test', $query);
 }