interface ConnectionInterface

Methods

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

Begin a fluent query against a database table.

raw(mixed $value)

Get a new raw query expression.

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 returns a generator.

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

Run an insert statement against the database.

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 PDO 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.

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
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.

PDO
getPdo()

Get the current PDO 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 PDO connection.

Details

at line 23
Builder table(Closure|Builder|UnitEnum|string $table, string|null $as = null)

Begin a fluent query against a database table.

Parameters

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

Return Value

Builder

at line 28
Expression raw(mixed $value)

Get a new raw query expression.

Parameters

mixed $value

Return Value

Expression

at line 33
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 40
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 45
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 50
Generator cursor(string $query, array $bindings = [], bool $useReadPdo = true, array $fetchUsing = [])

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

Parameters

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

Return Value

Generator

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

Run an insert statement against the database.

Parameters

string $query
array $bindings

Return Value

bool

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

Run an update statement against the database.

Parameters

string $query
array $bindings

Return Value

int

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

Run a delete statement against the database.

Parameters

string $query
array $bindings

Return Value

int

at line 70
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 75
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 80
bool unprepared(string $query)

Run a raw, unprepared query against the PDO connection.

Parameters

string $query

Return Value

bool

at line 85
array prepareBindings(array $bindings)

Prepare the query bindings for execution.

Parameters

array $bindings

Return Value

array

at line 97
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 102
void beginTransaction()

Start a new database transaction.

Return Value

void

at line 107
void commit()

Commit the active database transaction.

Return Value

void

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

Rollback the active database transaction.

Parameters

int|null $toLevel

Return Value

void

at line 117
int transactionLevel()

Get the number of active transactions.

Return Value

int

at line 122
array pretend(Closure $callback)

Execute the given callback in "dry run" mode.

Parameters

Closure $callback

Return Value

array

at line 127
string getDatabaseName()

Get the name of the connected database.

Return Value

string

at line 132
string|null getName()

Get the connection name.

Return Value

string|null

at line 137
string getDriverName()

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

Return Value

string

at line 142
string getDriverTitle()

Get a human-readable name for the database driver.

Return Value

string

at line 147
int|null threadCount()

Get the number of open connections to the database.

Return Value

int|null

at line 152
mixed withoutTablePrefix(Closure $callback)

Run a callback without the table prefix on the connection.

Parameters

Closure $callback

Return Value

mixed

at line 157
Builder getSchemaBuilder()

Get a schema builder instance for the connection.

Return Value

Builder

at line 162
Grammar getQueryGrammar()

Get the query grammar used by the connection.

Return Value

Grammar

at line 167
Processor getPostProcessor()

Get the query post processor used by the connection.

Return Value

Processor

at line 172
PDO getPdo()

Get the current PDO connection.

Return Value

PDO

at line 177
string getTablePrefix()

Get the table prefix for the connection.

Return Value

string

at line 182
string getServerVersion()

Get the database server version.

Return Value

string

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

Get an option from the configuration options.

Parameters

string|null $option

Return Value

mixed

at line 192
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 197
void recordsHaveBeenModified(bool $value = true)

Indicate if any records have been modified.

Parameters

bool $value

Return Value

void

at line 202
void disconnect()

Disconnect from the underlying PDO connection.

Return Value

void