QueryExecuted.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Database\Events;
  12. use Hyperf\Database\Connection;
  13. use Hyperf\Database\ConnectionInterface;
  14. use Throwable;
  15. class QueryExecuted
  16. {
  17. /**
  18. * The database connection name.
  19. *
  20. * @var string
  21. */
  22. public $connectionName;
  23. /**
  24. * @param string $sql the SQL query that was executed
  25. * @param array $bindings the array of query bindings
  26. * @param null|float $time the number of milliseconds it took to execute the query
  27. * @param Connection&ConnectionInterface $connection the database connection instance
  28. * @param null|array|int|Throwable $result the result of query
  29. */
  30. public function __construct(
  31. public string $sql,
  32. public array $bindings,
  33. public ?float $time,
  34. public ConnectionInterface $connection,
  35. public mixed $result = null
  36. ) {
  37. $this->connectionName = $connection->getName();
  38. }
  39. }