interface ConnectionInterface (View source)

Methods

table(Closure|Builder|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)

Run a select statement against the database.

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

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()

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.

Details

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

Begin a fluent query against a database table.

Parameters

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

Return Value

Builder

Expression raw(mixed $value)

Get a new raw query expression.

Parameters

mixed $value

Return Value

Expression

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

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

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

Run a select statement against the database.

Parameters

string $query
array $bindings
bool $useReadPdo

Return Value

array

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

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

Parameters

string $query
array $bindings
bool $useReadPdo

Return Value

Generator

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

Run an insert statement against the database.

Parameters

string $query
array $bindings

Return Value

bool

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

Run an update statement against the database.

Parameters

string $query
array $bindings

Return Value

int

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

Run a delete statement against the database.

Parameters

string $query
array $bindings

Return Value

int

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

Execute an SQL statement and return the boolean result.

Parameters

string $query
array $bindings

Return Value

bool

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

bool unprepared(string $query)

Run a raw, unprepared query against the PDO connection.

Parameters

string $query

Return Value

bool

array prepareBindings(array $bindings)

Prepare the query bindings for execution.

Parameters

array $bindings

Return Value

array

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

Execute a Closure within a transaction.

Parameters

Closure $callback
int $attempts

Return Value

mixed

Exceptions

Throwable

void beginTransaction()

Start a new database transaction.

Return Value

void

void commit()

Commit the active database transaction.

Return Value

void

void rollBack()

Rollback the active database transaction.

Return Value

void

int transactionLevel()

Get the number of active transactions.

Return Value

int

array pretend(Closure $callback)

Execute the given callback in "dry run" mode.

Parameters

Closure $callback

Return Value

array

string getDatabaseName()

Get the name of the connected database.

Return Value

string