PHP Интерфейс Doctrine\DBAL\Connection

Показать файл Открыть проект Примеры использования интерфейса

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

Свойство Тип Описание
$_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.
public getNestTransactionsWithSavepoints ( ) : boolean
Результат boolean

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