PHP 인터페이스 Doctrine\DBAL\Connection

파일 보기 프로젝트 열기: doctrine/dbal 0 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_config Doctrine\DBAL\Configuration
$_conn Doctrine\DBAL\Driver\Connection The wrapped driver connection.
$_driver Doctrine\DBAL\Driver The used DBAL driver.
$_eventManager Doctrine\Common\EventManager
$_expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
$_schemaManager Doctrine\DBAL\Schema\AbstractSchemaManager The schema manager.
$defaultFetchMode integer

공개 메소드들

메소드 설명
__construct ( array $params, Doctrine\DBAL\Driver $driver, Doctrine\DBAL\Configuration $config = null, Doctrine\Common\EventManager $eventManager = null ) Initializes a new instance of the Connection class.
beginTransaction ( ) : void Starts a transaction by suspending auto-commit mode.
close ( ) : void Closes the connection.
commit ( ) : void Commits the current transaction.
connect ( ) : boolean Establishes the connection with the database.
convertToDatabaseValue ( mixed $value, string $type ) : mixed Converts a given value to its database representation according to the conversion rules of a specific DBAL mapping type.
convertToPHPValue ( mixed $value, string $type ) : mixed Converts a given value to its PHP representation according to the conversion rules of a specific DBAL mapping type.
createQueryBuilder ( ) : Doctrine\DBAL\Query\QueryBuilder Creates a new instance of a SQL query builder.
createSavepoint ( string $savepoint ) : void Creates a new savepoint.
delete ( string $tableExpression, array $identifier, array $types = [] ) : integer Executes an SQL DELETE statement on a table.
errorCode ( ) : integer Fetches the SQLSTATE associated with the last database operation.
errorInfo ( ) : array Fetches extended error information associated with the last database operation.
exec ( string $statement ) : integer Executes an SQL statement and return the number of affected rows.
executeCacheQuery ( string $query, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp ) : Doctrine\DBAL\Driver\ResultStatement Executes a caching query.
executeQuery ( string $query, array $params = [], array $types = [], Doctrine\DBAL\Cache\QueryCacheProfile $qcp = null ) : Doctrine\DBAL\Driver\Statement Executes an, optionally parametrized, SQL query.
executeUpdate ( string $query, array $params = [], array $types = [] ) : integer Executes an SQL INSERT/UPDATE/DELETE query with the given parameters and returns the number of affected rows.
fetchAll ( string $sql, array $params = [], array $types = [] ) : array Prepares and executes an SQL query and returns the result as an associative array.
fetchArray ( string $statement, array $params = [], array $types = [] ) : array | boolean Prepares and executes an SQL query and returns the first row of the result as a numerically indexed array.
fetchAssoc ( string $statement, array $params = [], array $types = [] ) : array | boolean Prepares and executes an SQL query and returns the first row of the result as an associative array.
fetchColumn ( string $statement, array $params = [], integer $column, array $types = [] ) : mixed | boolean Prepares and executes an SQL query and returns the value of a single column of the first row of the result.
getConfiguration ( ) : Doctrine\DBAL\Configuration Gets the Configuration used by the Connection.
getDatabase ( ) : string Gets the name of the database this Connection is connected to.
getDatabasePlatform ( ) : Doctrine\DBAL\Platforms\AbstractPlatform Gets the DatabasePlatform for the connection.
getDriver ( ) : Doctrine\DBAL\Driver Gets the DBAL driver instance.
getEventManager ( ) : Doctrine\Common\EventManager Gets the EventManager used by the Connection.
getExpressionBuilder ( ) : Doctrine\DBAL\Query\Expression\ExpressionBuilder Gets the ExpressionBuilder for the connection.
getHost ( ) : string | null Gets the hostname of the currently connected database.
getNestTransactionsWithSavepoints ( ) : boolean Gets if nested transactions should use savepoints.
getParams ( ) : array Gets the parameters used during instantiation.
getPassword ( ) : string | null Gets the password used by this connection.
getPort ( ) : mixed Gets the port of the currently connected database.
getSchemaManager ( ) : Doctrine\DBAL\Schema\AbstractSchemaManager Gets the SchemaManager that can be used to inspect or change the database schema through the connection.
getTransactionIsolation ( ) : integer Gets the currently active transaction isolation level.
getTransactionNestingLevel ( ) : integer Returns the current transaction nesting level.
getUsername ( ) : string | null Gets the username used by this connection.
getWrappedConnection ( ) : Doctrine\DBAL\Driver\Connection Gets the wrapped driver connection.
insert ( string $tableExpression, array $data, array $types = [] ) : integer Inserts a table row with specified data.
isAutoCommit ( ) : boolean Returns the current auto-commit mode for this connection.
isConnected ( ) : boolean Whether an actual connection to the database is established.
isRollbackOnly ( ) : boolean Checks whether the current transaction is marked for rollback only.
isTransactionActive ( ) : boolean Checks whether a transaction is currently active.
lastInsertId ( string | null $seqName = null ) : string Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver.
ping ( ) : boolean Ping the server
prepare ( string $statement ) : Statement Prepares an SQL statement.
project ( string $query, array $params, Closur\Closure $function ) : array Executes an, optionally parametrized, SQL query and returns the result, applying a given projection/transformation function on each row of the result.
query ( ) : Doctrine\DBAL\Driver\Statement Executes an SQL statement, returning a result set as a Statement object.
quote ( mixed $input, string | null $type = null ) : string Quotes a given input parameter.
quoteIdentifier ( string $str ) : string Quotes a string so it can be safely used as a table or column name, even if it is a reserved name.
releaseSavepoint ( string $savepoint ) : void Releases the given savepoint.
resolveParams ( array $params, array $types ) : array Resolves the parameters to a format which can be displayed.
rollBack ( ) Cancels any database changes done during the current transaction.
rollbackSavepoint ( string $savepoint ) : void Rolls back to the given savepoint.
setAutoCommit ( boolean $autoCommit ) Sets auto-commit mode for this connection.
setFetchMode ( integer $fetchMode ) : void Sets the fetch mode.
setNestTransactionsWithSavepoints ( boolean $nestTransactionsWithSavepoints ) : void Sets if nested transactions should use savepoints.
setRollbackOnly ( ) : void Marks the current transaction so that the only possible outcome for the transaction to be rolled back.
setTransactionIsolation ( integer $level ) : integer Sets the transaction isolation level.
transactional ( Closur\Closure $func ) : mixed Executes a function in a transaction.
update ( string $tableExpression, array $data, array $identifier, array $types = [] ) : integer Executes an SQL UPDATE statement on a table.

보호된 메소드들

메소드 설명
_getNestedTransactionSavePointName ( ) : mixed Returns the savepoint name to use for nested transactions are false if they are not supported "savepointFormat" parameter is not set

비공개 메소드들

메소드 설명
_bindTypedValues ( Doctrine\DBAL\Driver\Statement $stmt, array $params, array $types ) : void Binds a set of parameters, some or all of which are typed with a PDO binding type or DBAL mapping type, to a given statement.
commitAll ( ) Commits all current nesting transactions.
detectDatabasePlatform ( ) Detects and sets the database platform.
extractTypeValues ( array $data, array $types ) : array Extract ordered type list from two associate key lists of data and types.
getBindingInfo ( mixed $value, mixed $type ) : array Gets the binding type of a given type. The given type can be a PDO or DBAL mapping type.
getDatabasePlatformVersion ( ) : string | null Returns the version of the related platform if applicable.

메소드 상세

__construct() 공개 메소드

Initializes a new instance of the Connection class.
public __construct ( array $params, Doctrine\DBAL\Driver $driver, Doctrine\DBAL\Configuration $config = null, Doctrine\Common\EventManager $eventManager = null )
$params array The connection parameters.
$driver Doctrine\DBAL\Driver The driver to use.
$config Doctrine\DBAL\Configuration The configuration, optional.
$eventManager Doctrine\Common\EventManager The event manager, optional.

_getNestedTransactionSavePointName() 보호된 메소드

Returns the savepoint name to use for nested transactions are false if they are not supported "savepointFormat" parameter is not set
protected _getNestedTransactionSavePointName ( ) : mixed
리턴 mixed A string with the savepoint name or false.

beginTransaction() 공개 메소드

Starts a transaction by suspending auto-commit mode.
public beginTransaction ( ) : void
리턴 void

close() 공개 메소드

Closes the connection.
public close ( ) : void
리턴 void

commit() 공개 메소드

Commits the current transaction.
public commit ( ) : void
리턴 void

connect() 공개 메소드

Establishes the connection with the database.
public connect ( ) : boolean
리턴 boolean TRUE if the connection was successfully established, FALSE if the connection is already open.

convertToDatabaseValue() 공개 메소드

Converts a given value to its database representation according to the conversion rules of a specific DBAL mapping type.
public convertToDatabaseValue ( mixed $value, string $type ) : mixed
$value mixed The value to convert.
$type string The name of the DBAL mapping type.
리턴 mixed The converted value.

convertToPHPValue() 공개 메소드

Converts a given value to its PHP representation according to the conversion rules of a specific DBAL mapping type.
public convertToPHPValue ( mixed $value, string $type ) : mixed
$value mixed The value to convert.
$type string The name of the DBAL mapping type.
리턴 mixed The converted type.

createQueryBuilder() 공개 메소드

Creates a new instance of a SQL query builder.
public createQueryBuilder ( ) : Doctrine\DBAL\Query\QueryBuilder
리턴 Doctrine\DBAL\Query\QueryBuilder

createSavepoint() 공개 메소드

Creates a new savepoint.
public createSavepoint ( string $savepoint ) : void
$savepoint string The name of the savepoint to create.
리턴 void

delete() 공개 메소드

Table expression and columns are not escaped and are not safe for user-input.
public delete ( string $tableExpression, array $identifier, array $types = [] ) : integer
$tableExpression string The expression of the table on which to delete.
$identifier array The deletion criteria. An associative array containing column-value pairs.
$types array The types of identifiers.
리턴 integer The number of affected rows.

errorCode() 공개 메소드

Fetches the SQLSTATE associated with the last database operation.
public errorCode ( ) : integer
리턴 integer The last error code.

errorInfo() 공개 메소드

Fetches extended error information associated with the last database operation.
public errorInfo ( ) : array
리턴 array The last error information.

exec() 공개 메소드

Executes an SQL statement and return the number of affected rows.
public exec ( string $statement ) : integer
$statement string
리턴 integer The number of affected rows.

executeCacheQuery() 공개 메소드

Executes a caching query.
public executeCacheQuery ( string $query, array $params, array $types, Doctrine\DBAL\Cache\QueryCacheProfile $qcp ) : Doctrine\DBAL\Driver\ResultStatement
$query string The SQL query to execute.
$params array The parameters to bind to the query, if any.
$types array The types the previous parameters are in.
$qcp Doctrine\DBAL\Cache\QueryCacheProfile The query cache profile.
리턴 Doctrine\DBAL\Driver\ResultStatement

executeQuery() 공개 메소드

If the query is parametrized, a prepared statement is used. If an SQLLogger is configured, the execution is logged.
public executeQuery ( string $query, array $params = [], array $types = [], Doctrine\DBAL\Cache\QueryCacheProfile $qcp = null ) : Doctrine\DBAL\Driver\Statement
$query string The SQL query to execute.
$params array The parameters to bind to the query, if any.
$types array The types the previous parameters are in.
$qcp Doctrine\DBAL\Cache\QueryCacheProfile The query cache profile, optional.
리턴 Doctrine\DBAL\Driver\Statement The executed statement.

executeUpdate() 공개 메소드

This method supports PDO binding types as well as DBAL mapping types.
public executeUpdate ( string $query, array $params = [], array $types = [] ) : integer
$query string The SQL query.
$params array The query parameters.
$types array The parameter types.
리턴 integer The number of affected rows.

fetchAll() 공개 메소드

Prepares and executes an SQL query and returns the result as an associative array.
public fetchAll ( string $sql, array $params = [], array $types = [] ) : array
$sql string The SQL query.
$params array The query parameters.
$types array The query parameter types.
리턴 array

fetchArray() 공개 메소드

Prepares and executes an SQL query and returns the first row of the result as a numerically indexed array.
public fetchArray ( string $statement, array $params = [], array $types = [] ) : array | boolean
$statement string The SQL query to be executed.
$params array The prepared statement params.
$types array The query parameter types.
리턴 array | boolean False is returned if no rows are found.

fetchAssoc() 공개 메소드

Prepares and executes an SQL query and returns the first row of the result as an associative array.
public fetchAssoc ( string $statement, array $params = [], array $types = [] ) : array | boolean
$statement string The SQL query.
$params array The query parameters.
$types array The query parameter types.
리턴 array | boolean False is returned if no rows are found.

fetchColumn() 공개 메소드

Prepares and executes an SQL query and returns the value of a single column of the first row of the result.
public fetchColumn ( string $statement, array $params = [], integer $column, array $types = [] ) : mixed | boolean
$statement string The SQL query to be executed.
$params array The prepared statement params.
$column integer The 0-indexed column number to retrieve.
$types array The query parameter types.
리턴 mixed | boolean False is returned if no rows are found.

getConfiguration() 공개 메소드

Gets the Configuration used by the Connection.
public getConfiguration ( ) : Doctrine\DBAL\Configuration
리턴 Doctrine\DBAL\Configuration

getDatabase() 공개 메소드

Gets the name of the database this Connection is connected to.
public getDatabase ( ) : string
리턴 string

getDatabasePlatform() 공개 메소드

Gets the DatabasePlatform for the connection.
public getDatabasePlatform ( ) : Doctrine\DBAL\Platforms\AbstractPlatform
리턴 Doctrine\DBAL\Platforms\AbstractPlatform

getDriver() 공개 메소드

Gets the DBAL driver instance.
public getDriver ( ) : Doctrine\DBAL\Driver
리턴 Doctrine\DBAL\Driver

getEventManager() 공개 메소드

Gets the EventManager used by the Connection.
public getEventManager ( ) : Doctrine\Common\EventManager
리턴 Doctrine\Common\EventManager

getExpressionBuilder() 공개 메소드

Gets the ExpressionBuilder for the connection.
public getExpressionBuilder ( ) : Doctrine\DBAL\Query\Expression\ExpressionBuilder
리턴 Doctrine\DBAL\Query\Expression\ExpressionBuilder

getHost() 공개 메소드

Gets the hostname of the currently connected database.
public getHost ( ) : string | null
리턴 string | null

getNestTransactionsWithSavepoints() 공개 메소드

Gets if nested transactions should use savepoints.

getParams() 공개 메소드

Gets the parameters used during instantiation.
public getParams ( ) : array
리턴 array

getPassword() 공개 메소드

Gets the password used by this connection.
public getPassword ( ) : string | null
리턴 string | null

getPort() 공개 메소드

Gets the port of the currently connected database.
public getPort ( ) : mixed
리턴 mixed

getSchemaManager() 공개 메소드

Gets the SchemaManager that can be used to inspect or change the database schema through the connection.
public getSchemaManager ( ) : Doctrine\DBAL\Schema\AbstractSchemaManager
리턴 Doctrine\DBAL\Schema\AbstractSchemaManager

getTransactionIsolation() 공개 메소드

Gets the currently active transaction isolation level.
public getTransactionIsolation ( ) : integer
리턴 integer The current transaction isolation level.

getTransactionNestingLevel() 공개 메소드

Returns the current transaction nesting level.
public getTransactionNestingLevel ( ) : integer
리턴 integer The nesting level. A value of 0 means there's no active transaction.

getUsername() 공개 메소드

Gets the username used by this connection.
public getUsername ( ) : string | null
리턴 string | null

getWrappedConnection() 공개 메소드

Gets the wrapped driver connection.
public getWrappedConnection ( ) : Doctrine\DBAL\Driver\Connection
리턴 Doctrine\DBAL\Driver\Connection

insert() 공개 메소드

Table expression and columns are not escaped and are not safe for user-input.
public insert ( string $tableExpression, array $data, array $types = [] ) : integer
$tableExpression string The expression of the table to insert data into, quoted or unquoted.
$data array An associative array containing column-value pairs.
$types array Types of the inserted data.
리턴 integer The number of affected rows.

isAutoCommit() 공개 메소드

Returns the current auto-commit mode for this connection.
또한 보기: setAutoCommit
public isAutoCommit ( ) : boolean
리턴 boolean True if auto-commit mode is currently enabled for this connection, false otherwise.

isConnected() 공개 메소드

Whether an actual connection to the database is established.
public isConnected ( ) : boolean
리턴 boolean

isRollbackOnly() 공개 메소드

Checks whether the current transaction is marked for rollback only.
public isRollbackOnly ( ) : boolean
리턴 boolean

isTransactionActive() 공개 메소드

Checks whether a transaction is currently active.
public isTransactionActive ( ) : boolean
리턴 boolean TRUE if a transaction is currently active, FALSE otherwise.

lastInsertId() 공개 메소드

Note: This method may not return a meaningful or consistent result across different drivers, because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY columns or sequences.
public lastInsertId ( string | null $seqName = null ) : string
$seqName string | null Name of the sequence object from which the ID should be returned.
리턴 string A string representation of the last inserted ID.

ping() 공개 메소드

When the server is not available the method returns FALSE. It is responsibility of the developer to handle this case and abort the request or reconnect manually:
public ping ( ) : boolean
리턴 boolean

prepare() 공개 메소드

Prepares an SQL statement.
public prepare ( string $statement ) : Statement
$statement string The SQL statement to prepare.
리턴 Statement The prepared statement.

project() 공개 메소드

Executes an, optionally parametrized, SQL query and returns the result, applying a given projection/transformation function on each row of the result.
public project ( string $query, array $params, Closur\Closure $function ) : array
$query string The SQL query to execute.
$params array The parameters, if any.
$function Closur\Closure The transformation function that is applied on each row. The function receives a single parameter, an array, that represents a row of the result set.
리턴 array The projected result of the query.

query() 공개 메소드

Executes an SQL statement, returning a result set as a Statement object.
public query ( ) : Doctrine\DBAL\Driver\Statement
리턴 Doctrine\DBAL\Driver\Statement

quote() 공개 메소드

Quotes a given input parameter.
public quote ( mixed $input, string | null $type = null ) : string
$input mixed The parameter to be quoted.
$type string | null The type of the parameter.
리턴 string The quoted parameter.

quoteIdentifier() 공개 메소드

Delimiting style depends on the underlying database platform that is being used. NOTE: Just because you CAN use quoted identifiers does not mean you SHOULD use them. In general, they end up causing way more problems than they solve.
public quoteIdentifier ( string $str ) : string
$str string The name to be quoted.
리턴 string The quoted name.

releaseSavepoint() 공개 메소드

Releases the given savepoint.
public releaseSavepoint ( string $savepoint ) : void
$savepoint string The name of the savepoint to release.
리턴 void

resolveParams() 공개 메소드

Resolves the parameters to a format which can be displayed.
public resolveParams ( array $params, array $types ) : array
$params array
$types array
리턴 array

rollBack() 공개 메소드

Cancels any database changes done during the current transaction.
public rollBack ( )

rollbackSavepoint() 공개 메소드

Rolls back to the given savepoint.
public rollbackSavepoint ( string $savepoint ) : void
$savepoint string The name of the savepoint to rollback to.
리턴 void

setAutoCommit() 공개 메소드

If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode. NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If this method is called and the auto-commit mode is not changed, the call is a no-op.
또한 보기: isAutoCommit
public setAutoCommit ( boolean $autoCommit )
$autoCommit boolean True to enable auto-commit mode; false to disable it.

setFetchMode() 공개 메소드

Sets the fetch mode.
public setFetchMode ( integer $fetchMode ) : void
$fetchMode integer
리턴 void

setNestTransactionsWithSavepoints() 공개 메소드

Sets if nested transactions should use savepoints.
public setNestTransactionsWithSavepoints ( boolean $nestTransactionsWithSavepoints ) : void
$nestTransactionsWithSavepoints boolean
리턴 void

setRollbackOnly() 공개 메소드

Marks the current transaction so that the only possible outcome for the transaction to be rolled back.
public setRollbackOnly ( ) : void
리턴 void

setTransactionIsolation() 공개 메소드

Sets the transaction isolation level.
public setTransactionIsolation ( integer $level ) : integer
$level integer The level to set.
리턴 integer

transactional() 공개 메소드

The function gets passed this Connection instance as an (optional) parameter. If an exception occurs during execution of the function or transaction commit, the transaction is rolled back and the exception re-thrown.
public transactional ( Closur\Closure $func ) : mixed
$func Closur\Closure The function to execute transactionally.
리턴 mixed The value returned by $func

update() 공개 메소드

Table expression and columns are not escaped and are not safe for user-input.
public update ( string $tableExpression, array $data, array $identifier, array $types = [] ) : integer
$tableExpression string The expression of the table to update quoted or unquoted.
$data array An associative array containing column-value pairs.
$identifier array The update criteria. An associative array containing column-value pairs.
$types array Types of the merged $data and $identifier arrays in that order.
리턴 integer The number of affected rows.

프로퍼티 상세

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

protected Configuration,Doctrine\DBAL $_config
리턴 Doctrine\DBAL\Configuration

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

The wrapped driver connection.
protected Connection,Doctrine\DBAL\Driver $_conn
리턴 Doctrine\DBAL\Driver\Connection

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

The used DBAL driver.
protected Driver,Doctrine\DBAL $_driver
리턴 Doctrine\DBAL\Driver

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

protected EventManager,Doctrine\Common $_eventManager
리턴 Doctrine\Common\EventManager

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

protected ExpressionBuilder,Doctrine\DBAL\Query\Expression $_expr
리턴 Doctrine\DBAL\Query\Expression\ExpressionBuilder

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

The schema manager.
protected AbstractSchemaManager,Doctrine\DBAL\Schema $_schemaManager
리턴 Doctrine\DBAL\Schema\AbstractSchemaManager

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

protected int $defaultFetchMode
리턴 integer