Query.php 1.6 KB

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