IDatabase.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /*
  3. * Part of Shuzanne - An extensible sequel to an open-source imageboard.
  4. *
  5. * @package Shuzanne
  6. * @author MisleadingName, Shuzanne Contributors
  7. * @license MPL v2.0
  8. *
  9. * This Source Code Form is subject to the terms of the Mozilla Public
  10. * License, v. 2.0. If a copy of the MPL was not distributed with this
  11. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  12. */
  13. namespace app\Interfaces;
  14. use PDO;
  15. interface IDatabase
  16. {
  17. /**
  18. * Closes the database connection.
  19. */
  20. public function CloseConnection(): void;
  21. /**
  22. * Binds a single parameter to the query.
  23. */
  24. public function Bind(string $param, mixed $value): void;
  25. /**
  26. * Binds multiple parameters to the query.
  27. */
  28. public function BindMore(array $params): void;
  29. /**
  30. * Executes a SQL query.
  31. *
  32. * @param string $query
  33. * @param array|null $params
  34. * @param int $fetchMode
  35. * @return mixed
  36. */
  37. public function Query(string $query, ?array $params = null, int $fetchMode = PDO::FETCH_ASSOC): mixed;
  38. /**
  39. * Executes a SQL query and returns the row count.
  40. *
  41. * @param string $query
  42. * @param array|null $params
  43. * @param int $fetchMode
  44. * @return int
  45. */
  46. public function QueryRowCount(string $query, ?array $params = null, int $fetchMode = PDO::FETCH_ASSOC): int;
  47. /**
  48. * Returns the ID of the last inserted row.
  49. */
  50. public function LastInsertId(): string;
  51. /**
  52. * Begins a transaction.
  53. */
  54. public function BeginTransaction(): bool;
  55. /**
  56. * Commits a transaction.
  57. */
  58. public function ExecuteTransaction(): bool;
  59. /**
  60. * Rolls back a transaction.
  61. */
  62. public function Rollback(): bool;
  63. /**
  64. * Returns a single column from a result set.
  65. *
  66. * @param string $query
  67. * @param array|null $params
  68. * @return array
  69. */
  70. public function Column(string $query, ?array $params = null): array;
  71. /**
  72. * Returns a single row from a result set.
  73. *
  74. * @param string $query
  75. * @param array|null $params
  76. * @param int $fetchMode
  77. * @return array
  78. */
  79. public function Row(string $query, ?array $params = null, int $fetchMode = PDO::FETCH_ASSOC): array;
  80. /**
  81. * Returns a single value from a result set.
  82. *
  83. * @param string $query
  84. * @param array|null $params
  85. * @return mixed
  86. */
  87. public function Single(string $query, ?array $params = null): mixed;
  88. }