IPreparedStatement.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\DB;
  8. use Doctrine\DBAL\Exception;
  9. use Doctrine\DBAL\ParameterType;
  10. use PDO;
  11. /**
  12. * This interface allows you to prepare a database query.
  13. *
  14. * This interface must not be implemented in your application but
  15. * instead obtained from IDBConnection::prepare.
  16. *
  17. * ```php
  18. * $prepare = $this->db->prepare($query->getSql());
  19. * ```
  20. *
  21. * @since 21.0.0
  22. */
  23. interface IPreparedStatement {
  24. /**
  25. * @return true
  26. *
  27. * @since 21.0.0
  28. * @deprecated 21.0.0 use \OCP\DB\IResult::closeCursor on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  29. */
  30. public function closeCursor(): bool;
  31. /**
  32. * @param int $fetchMode
  33. *
  34. * @return mixed
  35. *
  36. * @since 21.0.0
  37. * @deprecated 21.0.0 use \OCP\DB\IResult::fetch on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  38. */
  39. public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
  40. /**
  41. * @param int $fetchMode
  42. *
  43. * @return mixed[]
  44. *
  45. * @since 21.0.0
  46. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchAll on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  47. */
  48. public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC);
  49. /**
  50. * @return mixed
  51. *
  52. * @since 21.0.0
  53. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchColumn on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  54. */
  55. public function fetchColumn();
  56. /**
  57. * @return mixed
  58. *
  59. * @since 21.0.0
  60. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  61. */
  62. public function fetchOne();
  63. /**
  64. * @param int|string $param
  65. * @param mixed $value
  66. * @param int $type
  67. *
  68. * @return bool
  69. *
  70. * @throws Exception
  71. *
  72. * @since 21.0.0
  73. */
  74. public function bindValue($param, $value, $type = ParameterType::STRING): bool;
  75. /**
  76. * @param int|string $param
  77. * @param mixed $variable
  78. * @param int $type
  79. * @param int|null $length
  80. *
  81. * @return bool
  82. *
  83. * @throws Exception
  84. *
  85. * @since 21.0.0
  86. */
  87. public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool;
  88. /**
  89. * @param mixed[]|null $params
  90. *
  91. * @return IResult
  92. *
  93. * @since 21.0.0
  94. * @throws Exception
  95. */
  96. public function execute($params = null): IResult;
  97. /**
  98. * @return int
  99. *
  100. * @since 21.0.0
  101. *
  102. * @throws Exception
  103. * @deprecated 21.0.0 use \OCP\DB\IResult::rowCount on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  104. */
  105. public function rowCount(): int;
  106. }