1
0

Query.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Diagnostics;
  8. use OCP\Diagnostics\IQuery;
  9. class Query implements IQuery {
  10. private $sql;
  11. private $params;
  12. private $start;
  13. private $end;
  14. private $stack;
  15. /**
  16. * @param string $sql
  17. * @param array $params
  18. * @param int $start
  19. */
  20. public function __construct($sql, $params, $start, array $stack) {
  21. $this->sql = $sql;
  22. $this->params = $params;
  23. $this->start = $start;
  24. $this->stack = $stack;
  25. }
  26. public function end($time) {
  27. $this->end = $time;
  28. }
  29. /**
  30. * @return array
  31. */
  32. public function getParams() {
  33. return $this->params;
  34. }
  35. /**
  36. * @return string
  37. */
  38. public function getSql() {
  39. return $this->sql;
  40. }
  41. /**
  42. * @return float
  43. */
  44. public function getStart() {
  45. return $this->start;
  46. }
  47. /**
  48. * @return float
  49. */
  50. public function getDuration() {
  51. return $this->end - $this->start;
  52. }
  53. public function getStartTime() {
  54. return $this->start;
  55. }
  56. public function getStacktrace() {
  57. return $this->stack;
  58. }
  59. }