LoggedQuery.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Database\Log;
  16. /**
  17. * Contains a query string, the params used to executed it, time taken to do it
  18. * and the number of rows found or affected by its execution.
  19. *
  20. * @internal
  21. */
  22. class LoggedQuery
  23. {
  24. /**
  25. * Query string that was executed
  26. *
  27. * @var string
  28. */
  29. public $query = '';
  30. /**
  31. * Number of milliseconds this query took to complete
  32. *
  33. * @var int
  34. */
  35. public $took = 0;
  36. /**
  37. * Associative array with the params bound to the query string
  38. *
  39. * @var array
  40. */
  41. public $params = [];
  42. /**
  43. * Number of rows affected or returned by the query execution
  44. *
  45. * @var int
  46. */
  47. public $numRows = 0;
  48. /**
  49. * The exception that was thrown by the execution of this query
  50. *
  51. * @var \Exception|null
  52. */
  53. public $error;
  54. /**
  55. * Returns the string representation of this logged query
  56. *
  57. * @return string
  58. */
  59. public function __toString()
  60. {
  61. return "duration={$this->took} rows={$this->numRows} {$this->query}";
  62. }
  63. }