ConnectionInterface.php 3.2KB

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