Connection
public class Connection
www.doctrine-project.org
Field Summary | |
---|---|
final int | Constant for transaction isolation level READ COMMITTED. |
final int | Constant for transaction isolation level READ UNCOMMITTED. |
final int | Constant for transaction isolation level REPEATABLE READ. |
final int | Constant for transaction isolation level SERIALIZABLE. |
protected Doctrine\DBAL\Configuration | |
protected Doctrine\DBAL\Driver\Connection | The wrapped driver connection. |
protected Doctrine\DBAL\Driver | The used DBAL driver. |
protected Doctrine\Common\EventManager | |
protected Doctrine\DBAL\Platforms\AbstractPlatform | The DatabasePlatform object that provides information about the database platform used by the connection. |
protected Doctrine\DBAL\Schema\SchemaManager | The schema manager. |
Constructor Summary | |
---|---|
Connection(array params, Driver driver, Configuration config, EventManager eventManager) Initializes a new instance of the Connection class. |
Method Summary | |
---|---|
void | Starts a transaction by suspending auto-commit mode. |
void | close() Closes the connection. |
void | commit() Commits the current transaction. |
boolean | connect() Establishes the connection with the database. |
mixed | convertToDatabaseValue(mixed value, string type) Converts a given value to its database representation according to the conversion rules of a specific DBAL mapping type. |
mixed | convertToPHPValue(mixed value, string type) Converts a given value to its PHP representation according to the conversion rules of a specific DBAL mapping type. |
integer | delete(mixed tableName, array identifier, string table) Executes an SQL DELETE statement on a table. |
integer | Fetch the SQLSTATE associated with the last database operation. |
array | Fetch extended error information associated with the last database operation. |
integer | exec(string statement) Execute an SQL statement and return the number of affected rows. |
Doctrine\DBAL\Driver\Statement | executeQuery(string query, array params) Executes an, optionally parameterized, SQL query. |
integer | executeUpdate(string query, array params, array types) Executes an SQL INSERT/UPDATE/DELETE query with the given parameters and returns the number of affected rows. |
array | fetchAll(string sql, array params) Prepares and executes an SQL query and returns the result as an associative array. |
array | fetchArray(string statement, array params) Prepares and executes an SQL query and returns the first row of the result as a numerically indexed array. |
mixed | fetchColumn(string statement, array params, int colnum) Prepares and executes an SQL query and returns the value of a single column of the first row of the result. |
array | fetchRow(string statement, array params) Prepares and executes an SQL query and returns the first row of the result as an associative array. |
Doctrine\DBAL\Configuration | Gets the Configuration used by the Connection. |
string | Gets the name of the database this Connection is connected to. |
Doctrine\DBAL\Platforms\AbstractPlatform | Gets the DatabasePlatform for the connection. |
Doctrine\DBAL\Driver | Gets the DBAL driver instance. |
Doctrine\Common\EventManager | Gets the EventManager used by the Connection. |
string | getHost() Gets the hostname of the currently connected database. |
array | Gets the parameters used during instantiation. |
string | Gets the password used by this connection. |
mixed | getPort() Gets the port of the currently connected database. |
boolean | Check whether the current transaction is marked for rollback only. |
Doctrine\DBAL\Schema\SchemaManager | Gets the SchemaManager that can be used to inspect or change the database schema through the connection. |
integer | Gets the currently active transaction isolation level. |
integer | Returns the current transaction nesting level. |
string | Gets the username used by this connection. |
Doctrine\DBAL\Driver\Connection | Gets the wrapped driver connection. |
integer | insert(mixed tableName, array data, string table) Inserts a table row with specified data. |
boolean | Whether an actual connection to the database is established. |
boolean | Checks whether a transaction is currently active. |
string | lastInsertId(string seqName) Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver. |
Doctrine\DBAL\Driver\Statement | prepare(string statement) Prepares an SQL statement. |
mixed | project(string query, array params, mixed function, Closure mapper) Executes an, optionally parameterized, SQL query and returns the result, applying a given projection/transformation function on each row of the result. |
Doctrine\DBAL\Driver\Statement | query(string statement, integer fetchType) Executes an SQL statement, returning a result set as a Statement object. |
string | quote(mixed input, string type) Quotes a given input parameter. |
string | quoteIdentifier(string str) Quote a string so it can be safely used as a table or column name, even if it is a reserved name. |
void | rollback() Cancel any database changes done during the current transaction. |
void | setCharset(string charset) Sets the given charset on the current connection. |
void | Marks the current transaction so that the only possible outcome for the transaction to be rolled back. |
void | setTransactionIsolation(integer level) Sets the transaction isolation level. |
integer | update(mixed tableName, mixed data, array identifier, string table) Executes an SQL UPDATE statement on a table. |
public final int TRANSACTION_READ_COMMITTED = 2
Constant for transaction isolation level READ COMMITTED.
public final int TRANSACTION_READ_UNCOMMITTED = 1
Constant for transaction isolation level READ UNCOMMITTED.
public final int TRANSACTION_REPEATABLE_READ = 3
Constant for transaction isolation level REPEATABLE READ.
public final int TRANSACTION_SERIALIZABLE = 4
Constant for transaction isolation level SERIALIZABLE.
protected Doctrine\DBAL\Configuration $_config
protected Doctrine\DBAL\Driver\Connection $_conn
The wrapped driver connection.
protected Doctrine\DBAL\Driver $_driver
The used DBAL driver.
protected Doctrine\Common\EventManager $_eventManager
protected Doctrine\DBAL\Platforms\AbstractPlatform $_platform
The DatabasePlatform object that provides information about the database platform used by the connection.
protected Doctrine\DBAL\Schema\SchemaManager $_schemaManager
The schema manager.
public Connection(array params, Driver driver, Configuration config, EventManager eventManager)
Initializes a new instance of the Connection class.
public void beginTransaction()
Starts a transaction by suspending auto-commit mode.
public void close()
Closes the connection.
public void commit()
Commits the current transaction.
public boolean connect()
Establishes the connection with the database.
public mixed convertToDatabaseValue(mixed value, string type)
Converts a given value to its database representation according to the conversion rules of a specific DBAL mapping type.
public mixed convertToPHPValue(mixed value, string type)
Converts a given value to its PHP representation according to the conversion rules of a specific DBAL mapping type.
public integer delete(mixed tableName, array identifier, string table)
Executes an SQL DELETE statement on a table.
public integer errorCode()
Fetch the SQLSTATE associated with the last database operation.
public array errorInfo()
Fetch extended error information associated with the last database operation.
public integer exec(string statement)
Execute an SQL statement and return the number of affected rows.
public Doctrine\DBAL\Driver\Statement executeQuery(string query, array params)
Executes an, optionally parameterized, SQL query.
If the query is parameterized, a prepared statement is used. If an SQLLogger is configured, the execution is logged.
public integer executeUpdate(string query, array params, array types)
Executes an SQL INSERT/UPDATE/DELETE query with the given parameters and returns the number of affected rows.
This method supports PDO binding types as well as DBAL mapping types.
public array fetchAll(string sql, array params)
Prepares and executes an SQL query and returns the result as an associative array.
public array fetchArray(string statement, array params)
Prepares and executes an SQL query and returns the first row of the result as a numerically indexed array.
public mixed fetchColumn(string statement, array params, int colnum)
Prepares and executes an SQL query and returns the value of a single column of the first row of the result.
public array fetchRow(string statement, array params)
Prepares and executes an SQL query and returns the first row of the result as an associative array.
public Doctrine\DBAL\Configuration getConfiguration()
Gets the Configuration used by the Connection.
public string getDatabase()
Gets the name of the database this Connection is connected to.
public Doctrine\DBAL\Platforms\AbstractPlatform getDatabasePlatform()
Gets the DatabasePlatform for the connection.
public Doctrine\DBAL\Driver getDriver()
Gets the DBAL driver instance.
public Doctrine\Common\EventManager getEventManager()
Gets the EventManager used by the Connection.
public string getHost()
Gets the hostname of the currently connected database.
public array getParams()
Gets the parameters used during instantiation.
public string getPassword()
Gets the password used by this connection.
public mixed getPort()
Gets the port of the currently connected database.
public boolean getRollbackOnly()
Check whether the current transaction is marked for rollback only.
public Doctrine\DBAL\Schema\SchemaManager getSchemaManager()
Gets the SchemaManager that can be used to inspect or change the database schema through the connection.
public integer getTransactionIsolation()
Gets the currently active transaction isolation level.
public integer getTransactionNestingLevel()
Returns the current transaction nesting level.
public string getUsername()
Gets the username used by this connection.
public Doctrine\DBAL\Driver\Connection getWrappedConnection()
Gets the wrapped driver connection.
public integer insert(mixed tableName, array data, string table)
Inserts a table row with specified data.
public boolean isConnected()
Whether an actual connection to the database is established.
public boolean isTransactionActive()
Checks whether a transaction is currently active.
public string lastInsertId(string seqName)
Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver.
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 Doctrine\DBAL\Driver\Statement prepare(string statement)
Prepares an SQL statement.
public mixed project(string query, array params, mixed function, Closure mapper)
Executes an, optionally parameterized, SQL query and returns the result, applying a given projection/transformation function on each row of the result.
public Doctrine\DBAL\Driver\Statement query(string statement, integer fetchType)
Executes an SQL statement, returning a result set as a Statement object.
public string quote(mixed input, string type)
Quotes a given input parameter.
public string quoteIdentifier(string str)
Quote a string so it can be safely used as a table or column name, even if it is a reserved name.
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 void rollback()
Cancel any database changes done during the current transaction.
this method can be listened with onPreTransactionRollback and onTransactionRollback eventlistener methods
public void setCharset(string charset)
Sets the given charset on the current connection.
public void setRollbackOnly()
Marks the current transaction so that the only possible outcome for the transaction to be rolled back.
public void setTransactionIsolation(integer level)
Sets the transaction isolation level.
public integer update(mixed tableName, mixed data, array identifier, string table)
Executes an SQL UPDATE statement on a table.
A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like events, transaction isolation levels, configuration, emulated transaction nesting, lazy connecting and more.