Query.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Piotr Mrówczyński <mrow4a@yahoo.com>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OC\Diagnostics;
  25. use OCP\Diagnostics\IQuery;
  26. class Query implements IQuery {
  27. private $sql;
  28. private $params;
  29. private $start;
  30. private $end;
  31. private $stack;
  32. /**
  33. * @param string $sql
  34. * @param array $params
  35. * @param int $start
  36. */
  37. public function __construct($sql, $params, $start, array $stack) {
  38. $this->sql = $sql;
  39. $this->params = $params;
  40. $this->start = $start;
  41. $this->stack = $stack;
  42. }
  43. public function end($time) {
  44. $this->end = $time;
  45. }
  46. /**
  47. * @return array
  48. */
  49. public function getParams() {
  50. return $this->params;
  51. }
  52. /**
  53. * @return string
  54. */
  55. public function getSql() {
  56. return $this->sql;
  57. }
  58. /**
  59. * @return float
  60. */
  61. public function getStart() {
  62. return $this->start;
  63. }
  64. /**
  65. * @return float
  66. */
  67. public function getDuration() {
  68. return $this->end - $this->start;
  69. }
  70. public function getStartTime() {
  71. return $this->start;
  72. }
  73. public function getStacktrace() {
  74. return $this->stack;
  75. }
  76. }