TDbConnection class
TDbConnection represents a connection to a database.
TDbConnection works together with TDbCommand, TDbDataReader and TDbTransaction to provide data access to various DBMS in a common set of APIs. They are a thin wrapper of the PDO PHP extension.
To establish a connection, set Active to true after specifying ConnectionString, Username and Password.
Since 3.1.2, the connection charset can be set (for MySQL and PostgreSQL databases only) using the Charset property. The value of this property is database dependant. e.g. for mysql, you can use 'latin1' for cp1252 West European, 'utf8' for unicode, ...
The following example shows how to create a TDbConnection instance and establish the actual connection:
After the DB connection is established, one can execute an SQL statement like the following:
One can do prepared SQL execution and bind parameters to the prepared SQL:
To use transaction, do like the following:
TDbConnection provides a set of methods to support setting and querying of certain DBMS attributes, such as NullConversion.
Located in /Data/TDbConnection.php (line 84)
TComponent | --TDbConnection
Constructor.
Note, the DB connection is not established when this connection instance is created. Set Active property to true to establish the connection. Since 3.1.2, you can set the charset for MySql connection
Closes the currently active DB connection.
It does nothing if the connection is already closed.
Creates a command for execution.
Obtains a specific DB connection attribute information.
Returns the ID of the last inserted row or sequence value.
Opens DB connection if it is currently not
Quotes a column alias for use in a query.
Quotes a column name for use in a query.
Quotes a string for use in a query.
Quotes a table name for use in a query.
Open or close the DB connection.
Sets an attribute on the database connection.
Close the connection when serializing.
Inherited From TComponent
TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()
Documentation generated on Mon, 25 Jun 2012 14:38:00 +0200 by phpDocumentor 1.4.3