ConnectionInterface.php 3.6 KB

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