Class

eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler

class ConnectionHandler implements DatabaseHandler

Methods

static Connection createConnectionFromDSN(string|array $dsn)

static ConnectionHandler createFromConnection(Connection $connection)

Create a Connection Handler from given Doctrine $connection.

static ConnectionHandler createFromDSN(string|array $dsn)

Create a Connection Handler with corresponding Doctrine connection from DSN.

static array parseDSN(string $dsn)

Returns the Data Source Name as a structure containing the various parts of the DSN.

__construct(Connection $connection)

Connection getConnection()

string getName()

beginTransaction()

Begin a transaction.

commit()

Commit a transaction.

rollBack()

Rollback a transaction.

object prepare($query)

Prepare and return a statement.

string lastInsertId(string $sequenceName = null)

Retrieve the last auto incremet or sequence id.

bool useSequences()

exec(string $query)

Execute a query against the database.

SelectQuery createSelectQuery()

Create Select Query object.

InsertQuery createInsertQuery()

Create Insert Query object.

UpdateQuery createUpdateQuery()

Create update Query object.

DeleteQuery createDeleteQuery()

Create a Delete Query object.

string aliasedColumn(SelectQuery $query, string $columnName, string|null $tableName = null)

Creates an alias for $tableName, $columnName in $query.

string quoteColumn(string $columnName, string $tableName = null)

Returns a qualified identifier for $columnName in $tableName.

string quoteTable(string $tableName)

Returns a qualified identifier for $tableName.

string alias($name, $alias)

Custom alias method.

string quoteIdentifier(string $identifier)

Custom quote identifier method.

mixed getAutoIncrementValue(string $table, string $column)

Get auto increment value.

string getSequenceName(string $table, string $column)

Returns the name of the affected sequence.

Details

at line 29
static public Connection createConnectionFromDSN(string|array $dsn)

Parameters

string|array $dsn

Return Value

Connection

at line 47
static public ConnectionHandler createFromConnection(Connection $connection)

Create a Connection Handler from given Doctrine $connection.

Parameters

Connection $connection

Return Value

ConnectionHandler

at line 69
static public ConnectionHandler createFromDSN(string|array $dsn)

Create a Connection Handler with corresponding Doctrine connection from DSN.

Parameters

string|array $dsn

Return Value

ConnectionHandler

at line 125
static public array parseDSN(string $dsn)

Returns the Data Source Name as a structure containing the various parts of the DSN.

Additional keys can be added by appending a URI query string to the end of the DSN.

The format of the supplied DSN is in its fullest form: driver://user:password@protocol+host/database?option=8&another=true

Most variations are allowed: driver://user:password@protocol+host:110//usr/db_file.db?mode=0644 driver://user:password@host/dbname driver://user:password@host driver://user@host driver://host/dbname driver://host driver

This function is 'borrowed' from PEAR /DB.php .

Parameters

string $dsn Data Source Name to be parsed

Return Value

array an associative array with the following keys: + driver: Database backend used in PHP (mysql, odbc etc.) + host: Host specification (hostname[:port]) + dbname: Database to use on the DBMS server + username: User name for login + password: Password for login

at line 265
public __construct(Connection $connection)

Parameters

Connection $connection

at line 273
public Connection getConnection()

Return Value

Connection

at line 281
public string getName()

Return Value

string

at line 289
public beginTransaction()

Begin a transaction.

at line 301
public commit()

Commit a transaction.

at line 313
public rollBack()

Rollback a transaction.

at line 322
public object prepare($query)

Prepare and return a statement.

Statements are ducktyped, but need to work like PDOStatement.

Parameters

$query

Return Value

object

at line 334
public string lastInsertId(string $sequenceName = null)

Retrieve the last auto incremet or sequence id.

Parameters

string $sequenceName

Return Value

string

at line 342
public bool useSequences()

Return Value

bool

at line 352
public exec(string $query)

Execute a query against the database.

Parameters

string $query

at line 366
public SelectQuery createSelectQuery()

Create Select Query object.

Return Value

SelectQuery

at line 376
public InsertQuery createInsertQuery()

Create Insert Query object.

Return Value

InsertQuery

at line 386
public UpdateQuery createUpdateQuery()

Create update Query object.

Return Value

UpdateQuery

at line 396
public DeleteQuery createDeleteQuery()

Create a Delete Query object.

Return Value

DeleteQuery

at line 410
public string aliasedColumn(SelectQuery $query, string $columnName, string|null $tableName = null)

Creates an alias for $tableName, $columnName in $query.

Parameters

SelectQuery $query
string $columnName
string|null $tableName

Return Value

string

at line 429
public string quoteColumn(string $columnName, string $tableName = null)

Returns a qualified identifier for $columnName in $tableName.

Parameters

string $columnName
string $tableName

Return Value

string

at line 443
public string quoteTable(string $tableName)

Returns a qualified identifier for $tableName.

Parameters

string $tableName

Return Value

string

at line 460
public string alias($name, $alias)

Custom alias method.

Ignores some properties of identifier quoting, but since we use somehow sane table and column names, ourselves, this is fine.

This is an optimization and works around the ezcDB implementation.

Parameters

$name
$alias

Return Value

string

at line 477
public string quoteIdentifier(string $identifier)

Custom quote identifier method.

Ignores some properties of identifier quoting, but since we use somehow sane table and column names, ourselves, this is fine.

This is an optimization and works around the ezcDB implementation.

Parameters

string $identifier

Return Value

string

at line 494
public mixed getAutoIncrementValue(string $table, string $column)

Get auto increment value.

Returns the value used for autoincrement tables. Usually this will just be null. In case for sequence based RDBMS this method can return a proper value for the given column.

Parameters

string $table
string $column

Return Value

mixed

at line 507
public string getSequenceName(string $table, string $column)

Returns the name of the affected sequence.

Parameters

string $table
string $column

Return Value

string