ConnectionInterface.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. namespace Illuminate\Database;
  3. use Closure;
  4. interface ConnectionInterface
  5. {
  6. /**
  7. * Begin a fluent query against a database table.
  8. *
  9. * @param \Closure|\Illuminate\Database\Query\Builder|string $table
  10. * @param string|null $as
  11. * @return \Illuminate\Database\Query\Builder
  12. */
  13. public function table($table, $as = null);
  14. /**
  15. * Get a new raw query expression.
  16. *
  17. * @param mixed $value
  18. * @return \Illuminate\Database\Query\Expression
  19. */
  20. public function raw($value);
  21. /**
  22. * Run a select statement and return a single result.
  23. *
  24. * @param string $query
  25. * @param array $bindings
  26. * @param bool $useReadPdo
  27. * @return mixed
  28. */
  29. public function selectOne($query, $bindings = [], $useReadPdo = true);
  30. /**
  31. * Run a select statement against the database.
  32. *
  33. * @param string $query
  34. * @param array $bindings
  35. * @param bool $useReadPdo
  36. * @return array
  37. */
  38. public function select($query, $bindings = [], $useReadPdo = true);
  39. /**
  40. * Run a select statement against the database and returns a generator.
  41. *
  42. * @param string $query
  43. * @param array $bindings
  44. * @param bool $useReadPdo
  45. * @return \Generator
  46. */
  47. public function cursor($query, $bindings = [], $useReadPdo = true);
  48. /**
  49. * Run an insert statement against the database.
  50. *
  51. * @param string $query
  52. * @param array $bindings
  53. * @return bool
  54. */
  55. public function insert($query, $bindings = []);
  56. /**
  57. * Run an update statement against the database.
  58. *
  59. * @param string $query
  60. * @param array $bindings
  61. * @return int
  62. */
  63. public function update($query, $bindings = []);
  64. /**
  65. * Run a delete statement against the database.
  66. *
  67. * @param string $query
  68. * @param array $bindings
  69. * @return int
  70. */
  71. public function delete($query, $bindings = []);
  72. /**
  73. * Execute an SQL statement and return the boolean result.
  74. *
  75. * @param string $query
  76. * @param array $bindings
  77. * @return bool
  78. */
  79. public function statement($query, $bindings = []);
  80. /**
  81. * Run an SQL statement and get the number of rows affected.
  82. *
  83. * @param string $query
  84. * @param array $bindings
  85. * @return int
  86. */
  87. public function affectingStatement($query, $bindings = []);
  88. /**
  89. * Run a raw, unprepared query against the PDO connection.
  90. *
  91. * @param string $query
  92. * @return bool
  93. */
  94. public function unprepared($query);
  95. /**
  96. * Prepare the query bindings for execution.
  97. *
  98. * @param array $bindings
  99. * @return array
  100. */
  101. public function prepareBindings(array $bindings);
  102. /**
  103. * Execute a Closure within a transaction.
  104. *
  105. * @param \Closure $callback
  106. * @param int $attempts
  107. * @return mixed
  108. *
  109. * @throws \Throwable
  110. */
  111. public function transaction(Closure $callback, $attempts = 1);
  112. /**
  113. * Start a new database transaction.
  114. *
  115. * @return void
  116. */
  117. public function beginTransaction();
  118. /**
  119. * Commit the active database transaction.
  120. *
  121. * @return void
  122. */
  123. public function commit();
  124. /**
  125. * Rollback the active database transaction.
  126. *
  127. * @return void
  128. */
  129. public function rollBack();
  130. /**
  131. * Get the number of active transactions.
  132. *
  133. * @return int
  134. */
  135. public function transactionLevel();
  136. /**
  137. * Execute the given callback in "dry run" mode.
  138. *
  139. * @param \Closure $callback
  140. * @return array
  141. */
  142. public function pretend(Closure $callback);
  143. /**
  144. * Get the name of the connected database.
  145. *
  146. * @return string
  147. */
  148. public function getDatabaseName();
  149. }