ConnectionInterface.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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\Contracts\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 and return the first column of the first row.
  32. *
  33. * @param string $query
  34. * @param array $bindings
  35. * @param bool $useReadPdo
  36. * @return mixed
  37. *
  38. * @throws \Illuminate\Database\MultipleColumnsSelectedException
  39. */
  40. public function scalar($query, $bindings = [], $useReadPdo = true);
  41. /**
  42. * Run a select statement against the database.
  43. *
  44. * @param string $query
  45. * @param array $bindings
  46. * @param bool $useReadPdo
  47. * @return array
  48. */
  49. public function select($query, $bindings = [], $useReadPdo = true);
  50. /**
  51. * Run a select statement against the database and returns a generator.
  52. *
  53. * @param string $query
  54. * @param array $bindings
  55. * @param bool $useReadPdo
  56. * @return \Generator
  57. */
  58. public function cursor($query, $bindings = [], $useReadPdo = true);
  59. /**
  60. * Run an insert statement against the database.
  61. *
  62. * @param string $query
  63. * @param array $bindings
  64. * @return bool
  65. */
  66. public function insert($query, $bindings = []);
  67. /**
  68. * Run an update statement against the database.
  69. *
  70. * @param string $query
  71. * @param array $bindings
  72. * @return int
  73. */
  74. public function update($query, $bindings = []);
  75. /**
  76. * Run a delete statement against the database.
  77. *
  78. * @param string $query
  79. * @param array $bindings
  80. * @return int
  81. */
  82. public function delete($query, $bindings = []);
  83. /**
  84. * Execute an SQL statement and return the boolean result.
  85. *
  86. * @param string $query
  87. * @param array $bindings
  88. * @return bool
  89. */
  90. public function statement($query, $bindings = []);
  91. /**
  92. * Run an SQL statement and get the number of rows affected.
  93. *
  94. * @param string $query
  95. * @param array $bindings
  96. * @return int
  97. */
  98. public function affectingStatement($query, $bindings = []);
  99. /**
  100. * Run a raw, unprepared query against the PDO connection.
  101. *
  102. * @param string $query
  103. * @return bool
  104. */
  105. public function unprepared($query);
  106. /**
  107. * Prepare the query bindings for execution.
  108. *
  109. * @param array $bindings
  110. * @return array
  111. */
  112. public function prepareBindings(array $bindings);
  113. /**
  114. * Execute a Closure within a transaction.
  115. *
  116. * @param \Closure $callback
  117. * @param int $attempts
  118. * @return mixed
  119. *
  120. * @throws \Throwable
  121. */
  122. public function transaction(Closure $callback, $attempts = 1);
  123. /**
  124. * Start a new database transaction.
  125. *
  126. * @return void
  127. */
  128. public function beginTransaction();
  129. /**
  130. * Commit the active database transaction.
  131. *
  132. * @return void
  133. */
  134. public function commit();
  135. /**
  136. * Rollback the active database transaction.
  137. *
  138. * @return void
  139. */
  140. public function rollBack();
  141. /**
  142. * Get the number of active transactions.
  143. *
  144. * @return int
  145. */
  146. public function transactionLevel();
  147. /**
  148. * Execute the given callback in "dry run" mode.
  149. *
  150. * @param \Closure $callback
  151. * @return array
  152. */
  153. public function pretend(Closure $callback);
  154. /**
  155. * Get the name of the connected database.
  156. *
  157. * @return string
  158. */
  159. public function getDatabaseName();
  160. }