Propel 2 API
Class

Propel\Runtime\Connection\DebugPDO

class DebugPDO extends ConnectionWrapper

Connection wrapper class with debug enabled by default.

Class kept for BC sake.

Constants

PROPEL_ATTR_CACHE_PREPARES

Attribute to use to set whether to cache prepared statements.

Properties

$useDebug

Methods

__construct(ConnectionInterface $connection)

Creates a Connection instance.

from ConnectionWrapper
setName(string $name)

from ConnectionWrapper
string getName()

from ConnectionWrapper
ConnectionInterface getWrappedConnection()

from ConnectionWrapper
integer getNestedTransactionCount()

Gets the current transaction depth.

from ConnectionWrapper
boolean isInTransaction()

Is this PDO connection currently in-transaction? This is equivalent to asking whether the current nested transaction count is greater than 0.

from ConnectionWrapper
boolean isCommitable()

Check whether the connection contains a transaction that can be committed.

from ConnectionWrapper
boolean beginTransaction()

Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction.

from ConnectionWrapper
boolean commit()

Overrides PDO::commit() to only commit the transaction if we are in the outermost transaction nesting level.

from ConnectionWrapper
boolean rollBack()

Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost transaction nesting level

from ConnectionWrapper
boolean forceRollBack()

Rollback the whole transaction, even if this is a nested rollback and reset the nested transaction count to 0.

from ConnectionWrapper
boolean inTransaction()

Checks if inside a transaction.

from ConnectionWrapper
mixed getAttribute(string $attribute)

Retrieve a database connection attribute.

from ConnectionWrapper
boolean setAttribute(string $attribute, mixed $value)

Set an attribute.

from ConnectionWrapper
StatementInterface prepare(string $sql, array $driver_options = array())

Prepares a statement for execution and returns a statement object.

from ConnectionWrapper
integer exec(string $sql)

Execute an SQL statement and return the number of affected rows.

from ConnectionWrapper
StatementInterface query()

Executes an SQL statement, returning a result set as a PDOStatement object.

from ConnectionWrapper
string quote(string $string, int $parameter_type = 2)

Quotes a string for use in a query.

from ConnectionWrapper
DataFetcherInterface getSingleDataFetcher($data $data)

from ConnectionWrapper
DataFetcherInterface getDataFetcher($data $data)

from ConnectionWrapper
string lastInsertId(string $name = null)

Returns the ID of the last inserted row or sequence value.

from ConnectionWrapper
clearStatementCache()

Clears any stored prepared statements for this connection.

from ConnectionWrapper
integer getQueryCount()

Returns the number of queries this DebugPDO instance has performed on the database connection.

from ConnectionWrapper
integer incrementQueryCount()

Increments the number of queries performed by this DebugPDO instance.

from ConnectionWrapper
string getLastExecutedQuery()

Get the SQL code for the latest query executed by Propel

from ConnectionWrapper
setLastExecutedQuery(string $query)

Set the SQL code for the latest query executed by Propel

from ConnectionWrapper
useDebug(boolean $value = true)

Enable or disable the query debug features

from ConnectionWrapper
setLogMethods(array $logMethods)

from ConnectionWrapper
array getLogMethods()

from ConnectionWrapper
setLogger(LoggerInterface $logger)

{@inheritDoc}

from ConnectionWrapper
LoggerInterface getLogger()

Gets the logger to use for this connection.

from ConnectionWrapper
log(string $msg)

Logs the method call or the executed SQL statement.

from ConnectionWrapper
__call($method, $args)

Forward any call to a method not found to the wrapped connection.

from ConnectionWrapper
__destruct()

If so configured, makes an entry to the log of the state of this object just prior to its destruction.

from ConnectionWrapper

Details

in ConnectionWrapper at line 121
public __construct(ConnectionInterface $connection)

Creates a Connection instance.

Parameters

ConnectionInterface $connection

in ConnectionWrapper at line 132
public setName(string $name)

Parameters

string $name The datasource name associated to this connection

in ConnectionWrapper at line 140
public string getName()

Return Value

string The datasource name associated to this connection

in ConnectionWrapper at line 148
public ConnectionInterface getWrappedConnection()

Return Value

ConnectionInterface

in ConnectionWrapper at line 158
public integer getNestedTransactionCount()

Gets the current transaction depth.

Return Value

integer

in ConnectionWrapper at line 178
public boolean isInTransaction()

Is this PDO connection currently in-transaction? This is equivalent to asking whether the current nested transaction count is greater than 0.

Return Value

boolean

in ConnectionWrapper at line 189
public boolean isCommitable()

Check whether the connection contains a transaction that can be committed.

To be used in an environment where Propelexceptions are caught.

Return Value

boolean True if the connection is in a committable transaction

in ConnectionWrapper at line 199
public boolean beginTransaction()

Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction.

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionWrapper at line 220
public boolean commit()

Overrides PDO::commit() to only commit the transaction if we are in the outermost transaction nesting level.

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionWrapper at line 249
public boolean rollBack()

Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost transaction nesting level

Return Value

boolean Whether operation was successful.

in ConnectionWrapper at line 276
public boolean forceRollBack()

Rollback the whole transaction, even if this is a nested rollback and reset the nested transaction count to 0.

Return Value

boolean Whether operation was successful.

in ConnectionWrapper at line 302
public boolean inTransaction()

Checks if inside a transaction.

Return Value

boolean TRUE if a transaction is currently active, and FALSE if not.

in ConnectionWrapper at line 316
public mixed getAttribute(string $attribute)

Retrieve a database connection attribute.

Parameters

string $attribute The name of the attribute to retrieve, e.g. PDO::ATTR_AUTOCOMMIT

Return Value

mixed A successful call returns the value of the requested attribute. An unsuccessful call returns null.

in ConnectionWrapper at line 335
public boolean setAttribute(string $attribute, mixed $value)

Set an attribute.

Parameters

string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE')
mixed $value

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionWrapper at line 365
public StatementInterface prepare(string $sql, array $driver_options = array())

Prepares a statement for execution and returns a statement object.

Overrides PDO::prepare() in order to:
- Add logging and query counting if logging is true.
- Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true.

Parameters

string $sql This must be a valid SQL statement for the target database server.
array $driver_options One $array or more key => value pairs to set attribute values for the PDOStatement object that this method returns.

Return Value

StatementInterface

in ConnectionWrapper at line 392
public integer exec(string $sql)

Execute an SQL statement and return the number of affected rows.

Overrides PDO::exec() to log queries when required

Parameters

string $sql

Return Value

integer

in ConnectionWrapper at line 415
public StatementInterface query()

Executes an SQL statement, returning a result set as a PDOStatement object.

Despite its signature here, this method takes a variety of parameters.

Overrides PDO::query() to log queries when required

Return Value

StatementInterface

See also

http://php.net/manual/en/pdo.query.php for a description of the possible parameters.

in ConnectionWrapper at line 445
public string quote(string $string, int $parameter_type = 2)

Quotes a string for use in a query.

Places quotes around the input string (if required) and escapes special
characters within the input string, using a quoting style appropriate to
the underlying driver.

Parameters

string $string The string to be quoted.
int $parameter_type Provides a data type hint for drivers that have alternate quoting styles.

Return Value

string A quoted string that is theoretically safe to pass into an SQL statement. Returns FALSE if the driver does not support quoting in this way.

in ConnectionWrapper at line 453
public DataFetcherInterface getSingleDataFetcher($data $data)

Parameters

$data $data

Return Value

DataFetcherInterface

in ConnectionWrapper at line 461
public DataFetcherInterface getDataFetcher($data $data)

Parameters

$data $data

Return Value

DataFetcherInterface

in ConnectionWrapper at line 483
public string lastInsertId(string $name = null)

Returns the ID of the last inserted row or sequence value.

Returns the ID of the last inserted row, or the last value from a sequence
object, depending on the underlying driver. For example, PDO_PGSQL()
requires you to specify the name of a sequence object for the name parameter.

Parameters

string $name Name of the sequence object from which the ID should be returned.

Return Value

string If a sequence name was not specified for the name parameter, returns a string representing the row ID of the last row that was inserted into the database. If a sequence name was specified for the name parameter, returns a string representing the last value retrieved from the specified sequence object.

in ConnectionWrapper at line 491
public clearStatementCache()

Clears any stored prepared statements for this connection.

in ConnectionWrapper at line 504
public integer getQueryCount()

Returns the number of queries this DebugPDO instance has performed on the database connection.

When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances
are counted as well.

Return Value

integer

in ConnectionWrapper at line 516
public integer incrementQueryCount()

Increments the number of queries performed by this DebugPDO instance.

Returns the original number of queries (ie the value of $this->queryCount before calling this method).

Return Value

integer

in ConnectionWrapper at line 526
public string getLastExecutedQuery()

Get the SQL code for the latest query executed by Propel

Return Value

string Executable SQL code

in ConnectionWrapper at line 536
public setLastExecutedQuery(string $query)

Set the SQL code for the latest query executed by Propel

Parameters

string $query Executable SQL code

in ConnectionWrapper at line 546
public useDebug(boolean $value = true)

Enable or disable the query debug features

Parameters

boolean $value True to enable debug (default), false to disable it

in ConnectionWrapper at line 560
public setLogMethods(array $logMethods)

Parameters

array $logMethods

in ConnectionWrapper at line 568
public array getLogMethods()

Return Value

array

in ConnectionWrapper at line 581
public setLogger(LoggerInterface $logger)

{@inheritDoc}

Parameters

LoggerInterface $logger

in ConnectionWrapper at line 592
public LoggerInterface getLogger()

Gets the logger to use for this connection.

If no logger was set, returns the default logger from the Service Container.

Return Value

LoggerInterface A logger.

in ConnectionWrapper at line 606
public log(string $msg)

Logs the method call or the executed SQL statement.

Parameters

string $msg Message to log.

in ConnectionWrapper at line 623
public __call($method, $args)

Forward any call to a method not found to the wrapped connection.

Parameters

$method
$args

in ConnectionWrapper at line 633
public __destruct()

If so configured, makes an entry to the log of the state of this object just prior to its destruction.

See also

self::log()