PHP Класс Illuminate\Database\Connection

Наследование: implements Illuminate\Database\ConnectionInterface, use trait Illuminate\Database\DetectsDeadlocks, use trait Illuminate\Database\DetectsLostConnections
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$config array The database connection configuration options.
$database string The name of the connected database.
$doctrineConnection Doctrine\DBAL\Connection The instance of Doctrine connection.
$events Illuminate\Contracts\Events\Dispatcher The event dispatcher instance.
$fetchArgument mixed The argument for the fetch mode.
$fetchConstructorArgument array The constructor arguments for the PDO::FETCH_CLASS fetch mode.
$fetchMode integer The default fetch mode of the connection.
$loggingQueries boolean Indicates whether queries are being logged.
$pdo PDO The active PDO connection.
$postProcessor Illuminate\Database\Query\Processors\Processor The query post processor implementation.
$pretending boolean Indicates if the connection is in a "dry run".
$queryGrammar Illuminate\Database\Query\Grammars\Grammar The query grammar implementation.
$queryLog array All of the queries run against the connection.
$readPdo PDO The active PDO connection used for reads.
$reconnector callable The reconnector instance for the connection.
$schemaGrammar Illuminate\Database\Schema\Grammars\Grammar The schema grammar implementation.
$tablePrefix string The table prefix for the connection.
$transactions integer The number of active transactions.

Открытые методы

Метод Описание
__construct ( PDO | Closure $pdo, string $database = '', string $tablePrefix = '', array $config = [] ) : void Create a new database connection instance.
affectingStatement ( string $query, array $bindings = [] ) : integer Run an SQL statement and get the number of rows affected.
beginTransaction ( ) : void Start a new database transaction.
bindValues ( PDOStatement $statement, array $bindings ) : void Bind values to their parameters in the given statement.
commit ( ) : void Commit the active database transaction.
cursor ( string $query, array $bindings = [], boolean $useReadPdo = true ) : Generator Run a select statement against the database and returns a generator.
delete ( string $query, array $bindings = [] ) : integer Run a delete statement against the database.
disableQueryLog ( ) : void Disable the query log on the connection.
disconnect ( ) : void Disconnect from the underlying PDO connection.
enableQueryLog ( ) : void Enable the query log on the connection.
flushQueryLog ( ) : void Clear the query log.
getConfig ( string $option ) : mixed Get an option from the configuration options.
getDatabaseName ( ) : string Get the name of the connected database.
getDoctrineColumn ( string $table, string $column ) : Doctrine\DBAL\Schema\Column Get a Doctrine Schema Column instance.
getDoctrineConnection ( ) : Doctrine\DBAL\Connection Get the Doctrine DBAL database connection instance.
getDoctrineSchemaManager ( ) : Doctrine\DBAL\Schema\AbstractSchemaManager Get the Doctrine DBAL schema manager for the connection.
getDriverName ( ) : string Get the PDO driver name.
getEventDispatcher ( ) : Illuminate\Contracts\Events\Dispatcher Get the event dispatcher used by the connection.
getFetchArgument ( ) : mixed Get the fetch argument to be applied when selecting.
getFetchConstructorArgument ( ) : array Get custom constructor arguments for the PDO::FETCH_CLASS fetch mode.
getFetchMode ( ) : integer Get the default fetch mode for the connection.
getName ( ) : string | null Get the database connection name.
getPdo ( ) : PDO Get the current PDO connection.
getPostProcessor ( ) : Illuminate\Database\Query\Processors\Processor Get the query post processor used by the connection.
getQueryGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar Get the query grammar used by the connection.
getQueryLog ( ) : array Get the connection query log.
getReadPdo ( ) : PDO Get the current PDO connection used for reading.
getSchemaBuilder ( ) : Illuminate\Database\Schema\Builder Get a schema builder instance for the connection.
getSchemaGrammar ( ) : Illuminate\Database\Schema\Grammars\Grammar Get the schema grammar used by the connection.
getTablePrefix ( ) : string Get the table prefix for the connection.
insert ( string $query, array $bindings = [] ) : boolean Run an insert statement against the database.
isDoctrineAvailable ( ) : boolean Is Doctrine available?
listen ( Closure $callback ) : void Register a database query listener with the connection.
logQuery ( string $query, array $bindings, float | null $time = null ) : void Log a query in the connection's query log.
logging ( ) : boolean Determine whether we're logging queries.
prepareBindings ( array $bindings ) : array Prepare the query bindings for execution.
pretend ( Closure $callback ) : array Execute the given callback in "dry run" mode.
pretending ( ) : boolean Determine if the connection in a "dry run".
query ( ) : Builder Get a new query builder instance.
raw ( mixed $value ) : Illuminate\Database\Query\Expression Get a new raw query expression.
reconnect ( ) : void Reconnect to the database.
rollBack ( integer | null $toLevel = null ) : void Rollback the active database transaction.
select ( string $query, array $bindings = [], boolean $useReadPdo = true ) : array Run a select statement against the database.
selectFromWriteConnection ( string $query, array $bindings = [] ) : array Run a select statement against the database.
selectOne ( string $query, array $bindings = [] ) : mixed | null Run a select statement and return a single result.
setDatabaseName ( string $database ) : string Set the name of the connected database.
setEventDispatcher ( Illuminate\Contracts\Events\Dispatcher $events ) : void Set the event dispatcher instance on the connection.
setFetchMode ( integer $fetchMode, mixed $fetchArgument = null, array $fetchConstructorArgument = [] ) : integer Set the default fetch mode for the connection, and optional arguments for the given fetch mode.
setPdo ( PDO | null $pdo ) Set the PDO connection.
setPostProcessor ( Illuminate\Database\Query\Processors\Processor $processor ) : void Set the query post processor used by the connection.
setQueryGrammar ( Illuminate\Database\Query\Grammars\Grammar $grammar ) : void Set the query grammar used by the connection.
setReadPdo ( PDO | null $pdo ) Set the PDO connection used for reading.
setReconnector ( callable $reconnector ) Set the reconnect instance on the connection.
setSchemaGrammar ( Illuminate\Database\Schema\Grammars\Grammar $grammar ) : void Set the schema grammar used by the connection.
setTablePrefix ( string $prefix ) : void Set the table prefix in use by the connection.
statement ( string $query, array $bindings = [] ) : boolean Execute an SQL statement and return the boolean result.
table ( string $table ) : Builder Begin a fluent query against a database table.
transaction ( Closure $callback, integer $attempts = 1 ) : mixed Execute a Closure within a transaction.
transactionLevel ( ) : integer Get the number of active transactions.
unprepared ( string $query ) : boolean Run a raw, unprepared query against the PDO connection.
update ( string $query, array $bindings = [] ) : integer Run an update statement against the database.
useDefaultPostProcessor ( ) : void Set the query post processor to the default implementation.
useDefaultQueryGrammar ( ) : void Set the query grammar to the default implementation.
useDefaultSchemaGrammar ( ) : void Set the schema grammar to the default implementation.
withTablePrefix ( Illuminate\Database\Grammar $grammar ) : Illuminate\Database\Grammar Set the table prefix and return the grammar.

Защищенные методы

Метод Описание
fireConnectionEvent ( string $event ) : void Fire an event for this connection.
getDefaultPostProcessor ( ) : Illuminate\Database\Query\Processors\Processor Get the default post processor instance.
getDefaultQueryGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar Get the default query grammar instance.
getDefaultSchemaGrammar ( ) : Illuminate\Database\Schema\Grammars\Grammar Get the default schema grammar instance.
getElapsedTime ( integer $start ) : float Get the elapsed time since a given starting point.
getPdoForSelect ( boolean $useReadPdo = true ) : PDO Get the PDO connection to use for a select query.
reconnectIfMissingConnection ( ) : void Reconnect to the database if a PDO connection is missing.
run ( string $query, array $bindings, Closure $callback ) : mixed Run a SQL statement and log its execution context.
runQueryCallback ( string $query, array $bindings, Closure $callback ) : mixed Run a SQL statement.
tryAgainIfCausedByLostConnection ( Illuminate\Database\QueryException $e, string $query, array $bindings, Closure $callback ) : mixed Handle a query exception that occurred during query execution.

Описание методов

__construct() публичный Метод

Create a new database connection instance.
public __construct ( PDO | Closure $pdo, string $database = '', string $tablePrefix = '', array $config = [] ) : void
$pdo PDO | Closure
$database string
$tablePrefix string
$config array
Результат void

affectingStatement() публичный Метод

Run an SQL statement and get the number of rows affected.
public affectingStatement ( string $query, array $bindings = [] ) : integer
$query string
$bindings array
Результат integer

beginTransaction() публичный Метод

Start a new database transaction.
public beginTransaction ( ) : void
Результат void

bindValues() публичный Метод

Bind values to their parameters in the given statement.
public bindValues ( PDOStatement $statement, array $bindings ) : void
$statement PDOStatement
$bindings array
Результат void

commit() публичный Метод

Commit the active database transaction.
public commit ( ) : void
Результат void

cursor() публичный Метод

Run a select statement against the database and returns a generator.
public cursor ( string $query, array $bindings = [], boolean $useReadPdo = true ) : Generator
$query string
$bindings array
$useReadPdo boolean
Результат Generator

delete() публичный Метод

Run a delete statement against the database.
public delete ( string $query, array $bindings = [] ) : integer
$query string
$bindings array
Результат integer

disableQueryLog() публичный Метод

Disable the query log on the connection.
public disableQueryLog ( ) : void
Результат void

disconnect() публичный Метод

Disconnect from the underlying PDO connection.
public disconnect ( ) : void
Результат void

enableQueryLog() публичный Метод

Enable the query log on the connection.
public enableQueryLog ( ) : void
Результат void

fireConnectionEvent() защищенный Метод

Fire an event for this connection.
protected fireConnectionEvent ( string $event ) : void
$event string
Результат void

flushQueryLog() публичный Метод

Clear the query log.
public flushQueryLog ( ) : void
Результат void

getConfig() публичный Метод

Get an option from the configuration options.
public getConfig ( string $option ) : mixed
$option string
Результат mixed

getDatabaseName() публичный Метод

Get the name of the connected database.
public getDatabaseName ( ) : string
Результат string

getDefaultPostProcessor() защищенный Метод

Get the default post processor instance.
protected getDefaultPostProcessor ( ) : Illuminate\Database\Query\Processors\Processor
Результат Illuminate\Database\Query\Processors\Processor

getDefaultQueryGrammar() защищенный Метод

Get the default query grammar instance.
protected getDefaultQueryGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar
Результат Illuminate\Database\Query\Grammars\Grammar

getDefaultSchemaGrammar() защищенный Метод

Get the default schema grammar instance.
protected getDefaultSchemaGrammar ( ) : Illuminate\Database\Schema\Grammars\Grammar
Результат Illuminate\Database\Schema\Grammars\Grammar

getDoctrineColumn() публичный Метод

Get a Doctrine Schema Column instance.
public getDoctrineColumn ( string $table, string $column ) : Doctrine\DBAL\Schema\Column
$table string
$column string
Результат Doctrine\DBAL\Schema\Column

getDoctrineConnection() публичный Метод

Get the Doctrine DBAL database connection instance.
public getDoctrineConnection ( ) : Doctrine\DBAL\Connection
Результат Doctrine\DBAL\Connection

getDoctrineSchemaManager() публичный Метод

Get the Doctrine DBAL schema manager for the connection.
public getDoctrineSchemaManager ( ) : Doctrine\DBAL\Schema\AbstractSchemaManager
Результат Doctrine\DBAL\Schema\AbstractSchemaManager

getDriverName() публичный Метод

Get the PDO driver name.
public getDriverName ( ) : string
Результат string

getElapsedTime() защищенный Метод

Get the elapsed time since a given starting point.
protected getElapsedTime ( integer $start ) : float
$start integer
Результат float

getEventDispatcher() публичный Метод

Get the event dispatcher used by the connection.
public getEventDispatcher ( ) : Illuminate\Contracts\Events\Dispatcher
Результат Illuminate\Contracts\Events\Dispatcher

getFetchArgument() публичный Метод

Get the fetch argument to be applied when selecting.
public getFetchArgument ( ) : mixed
Результат mixed

getFetchConstructorArgument() публичный Метод

Get custom constructor arguments for the PDO::FETCH_CLASS fetch mode.
public getFetchConstructorArgument ( ) : array
Результат array

getFetchMode() публичный Метод

Get the default fetch mode for the connection.
public getFetchMode ( ) : integer
Результат integer

getName() публичный Метод

Get the database connection name.
public getName ( ) : string | null
Результат string | null

getPdo() публичный Метод

Get the current PDO connection.
public getPdo ( ) : PDO
Результат PDO

getPdoForSelect() защищенный Метод

Get the PDO connection to use for a select query.
protected getPdoForSelect ( boolean $useReadPdo = true ) : PDO
$useReadPdo boolean
Результат PDO

getPostProcessor() публичный Метод

Get the query post processor used by the connection.
public getPostProcessor ( ) : Illuminate\Database\Query\Processors\Processor
Результат Illuminate\Database\Query\Processors\Processor

getQueryGrammar() публичный Метод

Get the query grammar used by the connection.
public getQueryGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar
Результат Illuminate\Database\Query\Grammars\Grammar

getQueryLog() публичный Метод

Get the connection query log.
public getQueryLog ( ) : array
Результат array

getReadPdo() публичный Метод

Get the current PDO connection used for reading.
public getReadPdo ( ) : PDO
Результат PDO

getSchemaBuilder() публичный Метод

Get a schema builder instance for the connection.
public getSchemaBuilder ( ) : Illuminate\Database\Schema\Builder
Результат Illuminate\Database\Schema\Builder

getSchemaGrammar() публичный Метод

Get the schema grammar used by the connection.
public getSchemaGrammar ( ) : Illuminate\Database\Schema\Grammars\Grammar
Результат Illuminate\Database\Schema\Grammars\Grammar

getTablePrefix() публичный Метод

Get the table prefix for the connection.
public getTablePrefix ( ) : string
Результат string

insert() публичный Метод

Run an insert statement against the database.
public insert ( string $query, array $bindings = [] ) : boolean
$query string
$bindings array
Результат boolean

isDoctrineAvailable() публичный Метод

Is Doctrine available?
public isDoctrineAvailable ( ) : boolean
Результат boolean

listen() публичный Метод

Register a database query listener with the connection.
public listen ( Closure $callback ) : void
$callback Closure
Результат void

logQuery() публичный Метод

Log a query in the connection's query log.
public logQuery ( string $query, array $bindings, float | null $time = null ) : void
$query string
$bindings array
$time float | null
Результат void

logging() публичный Метод

Determine whether we're logging queries.
public logging ( ) : boolean
Результат boolean

prepareBindings() публичный Метод

Prepare the query bindings for execution.
public prepareBindings ( array $bindings ) : array
$bindings array
Результат array

pretend() публичный Метод

Execute the given callback in "dry run" mode.
public pretend ( Closure $callback ) : array
$callback Closure
Результат array

pretending() публичный Метод

Determine if the connection in a "dry run".
public pretending ( ) : boolean
Результат boolean

query() публичный Метод

Get a new query builder instance.
public query ( ) : Builder
Результат Illuminate\Database\Query\Builder

raw() публичный Метод

Get a new raw query expression.
public raw ( mixed $value ) : Illuminate\Database\Query\Expression
$value mixed
Результат Illuminate\Database\Query\Expression

reconnect() публичный Метод

Reconnect to the database.
public reconnect ( ) : void
Результат void

reconnectIfMissingConnection() защищенный Метод

Reconnect to the database if a PDO connection is missing.
protected reconnectIfMissingConnection ( ) : void
Результат void

rollBack() публичный Метод

Rollback the active database transaction.
public rollBack ( integer | null $toLevel = null ) : void
$toLevel integer | null
Результат void

run() защищенный Метод

Run a SQL statement and log its execution context.
protected run ( string $query, array $bindings, Closure $callback ) : mixed
$query string
$bindings array
$callback Closure
Результат mixed

runQueryCallback() защищенный Метод

Run a SQL statement.
protected runQueryCallback ( string $query, array $bindings, Closure $callback ) : mixed
$query string
$bindings array
$callback Closure
Результат mixed

select() публичный Метод

Run a select statement against the database.
public select ( string $query, array $bindings = [], boolean $useReadPdo = true ) : array
$query string
$bindings array
$useReadPdo boolean
Результат array

selectFromWriteConnection() публичный Метод

Run a select statement against the database.
public selectFromWriteConnection ( string $query, array $bindings = [] ) : array
$query string
$bindings array
Результат array

selectOne() публичный Метод

Run a select statement and return a single result.
public selectOne ( string $query, array $bindings = [] ) : mixed | null
$query string
$bindings array
Результат mixed | null

setDatabaseName() публичный Метод

Set the name of the connected database.
public setDatabaseName ( string $database ) : string
$database string
Результат string

setEventDispatcher() публичный Метод

Set the event dispatcher instance on the connection.
public setEventDispatcher ( Illuminate\Contracts\Events\Dispatcher $events ) : void
$events Illuminate\Contracts\Events\Dispatcher
Результат void

setFetchMode() публичный Метод

Set the default fetch mode for the connection, and optional arguments for the given fetch mode.
public setFetchMode ( integer $fetchMode, mixed $fetchArgument = null, array $fetchConstructorArgument = [] ) : integer
$fetchMode integer
$fetchArgument mixed
$fetchConstructorArgument array
Результат integer

setPdo() публичный Метод

Set the PDO connection.
public setPdo ( PDO | null $pdo )
$pdo PDO | null

setPostProcessor() публичный Метод

Set the query post processor used by the connection.
public setPostProcessor ( Illuminate\Database\Query\Processors\Processor $processor ) : void
$processor Illuminate\Database\Query\Processors\Processor
Результат void

setQueryGrammar() публичный Метод

Set the query grammar used by the connection.
public setQueryGrammar ( Illuminate\Database\Query\Grammars\Grammar $grammar ) : void
$grammar Illuminate\Database\Query\Grammars\Grammar
Результат void

setReadPdo() публичный Метод

Set the PDO connection used for reading.
public setReadPdo ( PDO | null $pdo )
$pdo PDO | null

setReconnector() публичный Метод

Set the reconnect instance on the connection.
public setReconnector ( callable $reconnector )
$reconnector callable

setSchemaGrammar() публичный Метод

Set the schema grammar used by the connection.
public setSchemaGrammar ( Illuminate\Database\Schema\Grammars\Grammar $grammar ) : void
$grammar Illuminate\Database\Schema\Grammars\Grammar
Результат void

setTablePrefix() публичный Метод

Set the table prefix in use by the connection.
public setTablePrefix ( string $prefix ) : void
$prefix string
Результат void

statement() публичный Метод

Execute an SQL statement and return the boolean result.
public statement ( string $query, array $bindings = [] ) : boolean
$query string
$bindings array
Результат boolean

table() публичный Метод

Begin a fluent query against a database table.
public table ( string $table ) : Builder
$table string
Результат Illuminate\Database\Query\Builder

transaction() публичный Метод

Execute a Closure within a transaction.
public transaction ( Closure $callback, integer $attempts = 1 ) : mixed
$callback Closure
$attempts integer
Результат mixed

transactionLevel() публичный Метод

Get the number of active transactions.
public transactionLevel ( ) : integer
Результат integer

tryAgainIfCausedByLostConnection() защищенный Метод

Handle a query exception that occurred during query execution.
protected tryAgainIfCausedByLostConnection ( Illuminate\Database\QueryException $e, string $query, array $bindings, Closure $callback ) : mixed
$e Illuminate\Database\QueryException
$query string
$bindings array
$callback Closure
Результат mixed

unprepared() публичный Метод

Run a raw, unprepared query against the PDO connection.
public unprepared ( string $query ) : boolean
$query string
Результат boolean

update() публичный Метод

Run an update statement against the database.
public update ( string $query, array $bindings = [] ) : integer
$query string
$bindings array
Результат integer

useDefaultPostProcessor() публичный Метод

Set the query post processor to the default implementation.
public useDefaultPostProcessor ( ) : void
Результат void

useDefaultQueryGrammar() публичный Метод

Set the query grammar to the default implementation.
public useDefaultQueryGrammar ( ) : void
Результат void

useDefaultSchemaGrammar() публичный Метод

Set the schema grammar to the default implementation.
public useDefaultSchemaGrammar ( ) : void
Результат void

withTablePrefix() публичный Метод

Set the table prefix and return the grammar.
public withTablePrefix ( Illuminate\Database\Grammar $grammar ) : Illuminate\Database\Grammar
$grammar Illuminate\Database\Grammar
Результат Illuminate\Database\Grammar

Описание свойств

$config защищенное свойство

The database connection configuration options.
protected array $config
Результат array

$database защищенное свойство

The name of the connected database.
protected string $database
Результат string

$doctrineConnection защищенное свойство

The instance of Doctrine connection.
protected Connection,Doctrine\DBAL $doctrineConnection
Результат Doctrine\DBAL\Connection

$events защищенное свойство

The event dispatcher instance.
protected Dispatcher,Illuminate\Contracts\Events $events
Результат Illuminate\Contracts\Events\Dispatcher

$fetchArgument защищенное свойство

The argument for the fetch mode.
protected mixed $fetchArgument
Результат mixed

$fetchConstructorArgument защищенное свойство

The constructor arguments for the PDO::FETCH_CLASS fetch mode.
protected array $fetchConstructorArgument
Результат array

$fetchMode защищенное свойство

The default fetch mode of the connection.
protected int $fetchMode
Результат integer

$loggingQueries защищенное свойство

Indicates whether queries are being logged.
protected bool $loggingQueries
Результат boolean

$pdo защищенное свойство

The active PDO connection.
protected PDO $pdo
Результат PDO

$postProcessor защищенное свойство

The query post processor implementation.
protected Processor,Illuminate\Database\Query\Processors $postProcessor
Результат Illuminate\Database\Query\Processors\Processor

$pretending защищенное свойство

Indicates if the connection is in a "dry run".
protected bool $pretending
Результат boolean

$queryGrammar защищенное свойство

The query grammar implementation.
protected Grammar,Illuminate\Database\Query\Grammars $queryGrammar
Результат Illuminate\Database\Query\Grammars\Grammar

$queryLog защищенное свойство

All of the queries run against the connection.
protected array $queryLog
Результат array

$readPdo защищенное свойство

The active PDO connection used for reads.
protected PDO $readPdo
Результат PDO

$reconnector защищенное свойство

The reconnector instance for the connection.
protected callable $reconnector
Результат callable

$schemaGrammar защищенное свойство

The schema grammar implementation.
protected Grammar,Illuminate\Database\Schema\Grammars $schemaGrammar
Результат Illuminate\Database\Schema\Grammars\Grammar

$tablePrefix защищенное свойство

The table prefix for the connection.
protected string $tablePrefix
Результат string

$transactions защищенное свойство

The number of active transactions.
protected int $transactions
Результат integer