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