IPreparedStatement.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  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
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\DB;
  25. use Doctrine\DBAL\Exception;
  26. use Doctrine\DBAL\ParameterType;
  27. use PDO;
  28. /**
  29. * This interface allows you to prepare a database query.
  30. *
  31. * This interface must not be implemented in your application but
  32. * instead obtained from IDBConnection::prepare.
  33. *
  34. * ```php
  35. * $prepare = $this->db->prepare($query->getSql());
  36. * ```
  37. *
  38. * @since 21.0.0
  39. */
  40. interface IPreparedStatement {
  41. /**
  42. * @return true
  43. *
  44. * @since 21.0.0
  45. * @deprecated 21.0.0 use \OCP\DB\IResult::closeCursor on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  46. */
  47. public function closeCursor(): bool;
  48. /**
  49. * @param int $fetchMode
  50. *
  51. * @return mixed
  52. *
  53. * @since 21.0.0
  54. * @deprecated 21.0.0 use \OCP\DB\IResult::fetch on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  55. */
  56. public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
  57. /**
  58. * @param int $fetchMode
  59. *
  60. * @return mixed[]
  61. *
  62. * @since 21.0.0
  63. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchAll on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  64. */
  65. public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC);
  66. /**
  67. * @return mixed
  68. *
  69. * @since 21.0.0
  70. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchColumn on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  71. */
  72. public function fetchColumn();
  73. /**
  74. * @return mixed
  75. *
  76. * @since 21.0.0
  77. * @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  78. */
  79. public function fetchOne();
  80. /**
  81. * @param int|string $param
  82. * @param mixed $value
  83. * @param int $type
  84. *
  85. * @return bool
  86. *
  87. * @throws Exception
  88. *
  89. * @since 21.0.0
  90. */
  91. public function bindValue($param, $value, $type = ParameterType::STRING): bool;
  92. /**
  93. * @param int|string $param
  94. * @param mixed $variable
  95. * @param int $type
  96. * @param int|null $length
  97. *
  98. * @return bool
  99. *
  100. * @throws Exception
  101. *
  102. * @since 21.0.0
  103. */
  104. public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool;
  105. /**
  106. * @param mixed[]|null $params
  107. *
  108. * @return IResult
  109. *
  110. * @since 21.0.0
  111. * @throws Exception
  112. */
  113. public function execute($params = null): IResult;
  114. /**
  115. * @return int
  116. *
  117. * @since 21.0.0
  118. *
  119. * @throws Exception
  120. * @deprecated 21.0.0 use \OCP\DB\IResult::rowCount on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
  121. */
  122. public function rowCount(): int;
  123. }