PHP 클래스 Doctrine\DBAL\Connections\MasterSlaveConnection

Connection can be used with master-slave setups. Important for the understanding of this connection should be how and when it picks the slave or master. 1. Slave if master was never picked before and ONLY if 'getWrappedConnection' or 'executeQuery' is used. 2. Master picked when 'exec', 'executeUpdate', 'insert', 'delete', 'update', 'createSavepoint', 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or 'prepare' is called. 3. If master was picked once during the lifetime of the connection it will always get picked afterwards. 4. One slave connection is randomly picked ONCE during a request. ATTENTION: You can write to the slave with this connection if you execute a write query without opening up a transaction. For example: $conn = DriverManager::getConnection(...); $conn->executeQuery("DELETE FROM table"); Be aware that Connection#executeQuery is a method specifically for READ operations only. This connection is limited to slave operations using the Connection#executeQuery operation only, because it wouldn't be compatible with the ORM or SchemaManager code otherwise. Both use all the other operations in a context where writes could happen to a slave, which makes this restricted approach necessary. You can manually connect to the master at any time by calling: $conn->connect('master'); Instantiation through the DriverManager looks like:
저자: Lars Strojny ([email protected])
저자: Benjamin Eberlei ([email protected])
상속: extends Doctrine\DBAL\Connection
파일 보기 프로젝트 열기: doctrine/dbal 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$connections Doctrine\DBAL\Driver\Connection[] Master and slave connection (one of the randomly picked slaves).
$keepSlave boolean You can keep the slave connection and then switch back to it during the request if you know what you are doing.

공개 메소드들

메소드 설명
__construct ( array $params, Doctrine\DBAL\Driver $driver, Doctrine\DBAL\Configuration $config = null, Doctrine\Common\EventManager $eventManager = null ) Creates Master Slave Connection.
beginTransaction ( ) {@inheritDoc}
close ( ) {@inheritDoc}
commit ( ) {@inheritDoc}
connect ( $connectionName = null ) {@inheritDoc}
createSavepoint ( $savepoint ) {@inheritDoc}
delete ( $tableName, array $identifier, array $types = [] ) {@inheritDoc}
exec ( $statement ) {@inheritDoc}
executeUpdate ( $query, array $params = [], array $types = [] ) {@inheritDoc}
insert ( $tableName, array $data, array $types = [] ) {@inheritDoc}
isConnectedToMaster ( ) : boolean Checks if the connection is currently towards the master or not.
prepare ( $statement ) {@inheritDoc}
query ( ) {@inheritDoc}
releaseSavepoint ( $savepoint ) {@inheritDoc}
rollBack ( ) {@inheritDoc}
rollbackSavepoint ( $savepoint ) {@inheritDoc}
update ( $tableName, array $data, array $identifier, array $types = [] ) {@inheritDoc}

보호된 메소드들

메소드 설명
chooseConnectionConfiguration ( string $connectionName, array $params ) : mixed
connectTo ( string $connectionName ) : Doctrine\DBAL\Driver Connects to a specific connection.

메소드 상세

__construct() 공개 메소드

Creates Master Slave Connection.
public __construct ( array $params, Doctrine\DBAL\Driver $driver, Doctrine\DBAL\Configuration $config = null, Doctrine\Common\EventManager $eventManager = null )
$params array
$driver Doctrine\DBAL\Driver
$config Doctrine\DBAL\Configuration
$eventManager Doctrine\Common\EventManager

beginTransaction() 공개 메소드

{@inheritDoc}
public beginTransaction ( )

chooseConnectionConfiguration() 보호된 메소드

protected chooseConnectionConfiguration ( string $connectionName, array $params ) : mixed
$connectionName string
$params array
리턴 mixed

close() 공개 메소드

{@inheritDoc}
public close ( )

commit() 공개 메소드

{@inheritDoc}
public commit ( )

connect() 공개 메소드

{@inheritDoc}
public connect ( $connectionName = null )

connectTo() 보호된 메소드

Connects to a specific connection.
protected connectTo ( string $connectionName ) : Doctrine\DBAL\Driver
$connectionName string
리턴 Doctrine\DBAL\Driver

createSavepoint() 공개 메소드

{@inheritDoc}
public createSavepoint ( $savepoint )

delete() 공개 메소드

{@inheritDoc}
public delete ( $tableName, array $identifier, array $types = [] )
$identifier array
$types array

exec() 공개 메소드

{@inheritDoc}
public exec ( $statement )

executeUpdate() 공개 메소드

{@inheritDoc}
public executeUpdate ( $query, array $params = [], array $types = [] )
$params array
$types array

insert() 공개 메소드

{@inheritDoc}
public insert ( $tableName, array $data, array $types = [] )
$data array
$types array

isConnectedToMaster() 공개 메소드

Checks if the connection is currently towards the master or not.
public isConnectedToMaster ( ) : boolean
리턴 boolean

prepare() 공개 메소드

{@inheritDoc}
public prepare ( $statement )

query() 공개 메소드

{@inheritDoc}
public query ( )

releaseSavepoint() 공개 메소드

{@inheritDoc}
public releaseSavepoint ( $savepoint )

rollBack() 공개 메소드

{@inheritDoc}
public rollBack ( )

rollbackSavepoint() 공개 메소드

{@inheritDoc}
public rollbackSavepoint ( $savepoint )

update() 공개 메소드

{@inheritDoc}
public update ( $tableName, array $data, array $identifier, array $types = [] )
$data array
$identifier array
$types array

프로퍼티 상세

$connections 보호되어 있는 프로퍼티

Master and slave connection (one of the randomly picked slaves).
protected Connection[],Doctrine\DBAL\Driver $connections
리턴 Doctrine\DBAL\Driver\Connection[]

$keepSlave 보호되어 있는 프로퍼티

You can keep the slave connection and then switch back to it during the request if you know what you are doing.
protected bool $keepSlave
리턴 boolean