interface ConnectionInterface

Methods

table(Closure|Builder|Builder|Relation|Expression|UnitEnum|string $table, string|null $as = null)

Begin a fluent query against a database table.

raw(mixed $value)

Get a new raw query expression.

string
escape(mixed $value, bool $binary = false)

Escape a value for safe SQL embedding.

mixed
selectOne(string $query, array $bindings = [], bool $useReadPdo = true)

Run a select statement and return a single result.

mixed
scalar(string $query, array $bindings = [], bool $useReadPdo = true)

Run a select statement and return the first column of the first row.

array
select(string $query, array $bindings = [], bool $useReadPdo = true, array $fetchUsing = [])

Run a select statement against the database.

cursor(string $query, array $bindings = [], bool $useReadPdo = true, array $fetchUsing = [])

Run a select statement against the database and return a generator.

bool
insert(string $query, array $bindings = [])

Run an insert statement against the database.

int|string
getLastInsertId(string|null $sequence = null)

Get the last insert ID.

int
update(string $query, array $bindings = [])

Run an update statement against the database.

int
delete(string $query, array $bindings = [])

Run a delete statement against the database.

bool
statement(string $query, array $bindings = [])

Execute an SQL statement and return the boolean result.

int
affectingStatement(string $query, array $bindings = [])

Run an SQL statement and get the number of rows affected.

bool
unprepared(string $query)

Run a raw, unprepared query against the connection.

array
prepareBindings(array $bindings)

Prepare the query bindings for execution.

mixed
transaction(Closure $callback, int $attempts = 1)

Execute a Closure within a transaction.

void
beginTransaction()

Start a new database transaction.

void
commit()

Commit the active database transaction.

void
rollBack(int|null $toLevel = null)

Rollback the active database transaction.

int
transactionLevel()

Get the number of active transactions.

bool
inTransaction()

Determine whether the connection has an active physical transaction.

array
pretend(Closure $callback)

Execute the given callback in "dry run" mode.

string
getDatabaseName()

Get the name of the connected database.

string|null
getName()

Get the connection name.

string|null
getNameWithReadWriteType()

Get the database connection with its read / write type.

string|null
getWritableName()

Get the connection name to retain when subsequent operations may write.

string
getDriverName()

Get the database driver name (e.g. "mysql", "pgsql", "sqlite").

string
getDriverTitle()

Get a human-readable name for the database driver.

int|null
threadCount()

Get the number of open connections to the database.

mixed
withoutTablePrefix(Closure $callback)

Run a callback without the table prefix on the connection.

getSchemaBuilder()

Get a schema builder instance for the connection.

getQueryGrammar()

Get the query grammar used by the connection.

getPostProcessor()

Get the query post processor used by the connection.

string
getTablePrefix()

Get the table prefix for the connection.

string
getServerVersion()

Get the database server version.

mixed
getConfig(string|null $option = null)

Get an option from the configuration options.

array
selectFromWriteConnection(string $query, array $bindings = [])

Run a select statement against the database using the write connection.

void
recordsHaveBeenModified(bool $value = true)

Indicate if any records have been modified.

void
disconnect()

Disconnect from the underlying driver resources.

Details

at line 26
Builder table(Closure|Builder|Builder|Relation|Expression|UnitEnum|string $table, string|null $as = null)

Begin a fluent query against a database table.

Parameters

Closure|Builder|Builder|Relation|Expression|UnitEnum|string $table
string|null $as

Return Value

Builder

at line 31
Expression raw(mixed $value)

Get a new raw query expression.

Parameters

mixed $value

Return Value

Expression

at line 36
string escape(mixed $value, bool $binary = false)

Escape a value for safe SQL embedding.

Parameters

mixed $value
bool $binary

Return Value

string

at line 41
mixed selectOne(string $query, array $bindings = [], bool $useReadPdo = true)

Run a select statement and return a single result.

Parameters

string $query
array $bindings
bool $useReadPdo

Return Value

mixed

at line 48
mixed scalar(string $query, array $bindings = [], bool $useReadPdo = true)

Run a select statement and return the first column of the first row.

Parameters

string $query
array $bindings
bool $useReadPdo

Return Value

mixed

Exceptions

MultipleColumnsSelectedException

at line 53
array select(string $query, array $bindings = [], bool $useReadPdo = true, array $fetchUsing = [])

Run a select statement against the database.

Parameters

string $query
array $bindings
bool $useReadPdo
array $fetchUsing

Return Value

array

at line 60
Generator cursor(string $query, array $bindings = [], bool $useReadPdo = true, array $fetchUsing = [])

Run a select statement against the database and return a generator.

Parameters

string $query
array $bindings
bool $useReadPdo
array $fetchUsing

Return Value

Generator

at line 65
bool insert(string $query, array $bindings = [])

Run an insert statement against the database.

Parameters

string $query
array $bindings

Return Value

bool

at line 70
int|string getLastInsertId(string|null $sequence = null)

Get the last insert ID.

Parameters

string|null $sequence

Return Value

int|string

at line 75
int update(string $query, array $bindings = [])

Run an update statement against the database.

Parameters

string $query
array $bindings

Return Value

int

at line 80
int delete(string $query, array $bindings = [])

Run a delete statement against the database.

Parameters

string $query
array $bindings

Return Value

int

at line 85
bool statement(string $query, array $bindings = [])

Execute an SQL statement and return the boolean result.

Parameters

string $query
array $bindings

Return Value

bool

at line 90
int affectingStatement(string $query, array $bindings = [])

Run an SQL statement and get the number of rows affected.

Parameters

string $query
array $bindings

Return Value

int

at line 95
bool unprepared(string $query)

Run a raw, unprepared query against the connection.

Parameters

string $query

Return Value

bool

at line 100
array prepareBindings(array $bindings)

Prepare the query bindings for execution.

Parameters

array $bindings

Return Value

array

at line 112
mixed transaction(Closure $callback, int $attempts = 1)

Execute a Closure within a transaction.

Parameters

Closure $callback
int $attempts

Return Value

mixed

Exceptions

Throwable

at line 117
void beginTransaction()

Start a new database transaction.

Return Value

void

at line 122
void commit()

Commit the active database transaction.

Return Value

void

at line 127
void rollBack(int|null $toLevel = null)

Rollback the active database transaction.

Parameters

int|null $toLevel

Return Value

void

at line 134
int transactionLevel()

Get the number of active transactions.

Return Value

int

at line 139
bool inTransaction()

Determine whether the connection has an active physical transaction.

Return Value

bool

at line 144
array pretend(Closure $callback)

Execute the given callback in "dry run" mode.

Parameters

Closure $callback

Return Value

array

at line 149
string getDatabaseName()

Get the name of the connected database.

Return Value

string

at line 154
string|null getName()

Get the connection name.

Return Value

string|null

at line 159
string|null getNameWithReadWriteType()

Get the database connection with its read / write type.

Return Value

string|null

at line 164
string|null getWritableName()

Get the connection name to retain when subsequent operations may write.

Return Value

string|null

at line 169
string getDriverName()

Get the database driver name (e.g. "mysql", "pgsql", "sqlite").

Return Value

string

at line 174
string getDriverTitle()

Get a human-readable name for the database driver.

Return Value

string

at line 179
int|null threadCount()

Get the number of open connections to the database.

Return Value

int|null

at line 189
mixed withoutTablePrefix(Closure $callback)

Run a callback without the table prefix on the connection.

Parameters

Closure $callback

Return Value

mixed

at line 194
Builder getSchemaBuilder()

Get a schema builder instance for the connection.

Return Value

Builder

at line 199
Grammar getQueryGrammar()

Get the query grammar used by the connection.

Return Value

Grammar

at line 204
Processor getPostProcessor()

Get the query post processor used by the connection.

Return Value

Processor

at line 209
string getTablePrefix()

Get the table prefix for the connection.

Return Value

string

at line 214
string getServerVersion()

Get the database server version.

Return Value

string

at line 219
mixed getConfig(string|null $option = null)

Get an option from the configuration options.

Parameters

string|null $option

Return Value

mixed

at line 224
array selectFromWriteConnection(string $query, array $bindings = [])

Run a select statement against the database using the write connection.

Parameters

string $query
array $bindings

Return Value

array

at line 229
void recordsHaveBeenModified(bool $value = true)

Indicate if any records have been modified.

Parameters

bool $value

Return Value

void

at line 234
void disconnect()

Disconnect from the underlying driver resources.

Return Value

void