Propel 2 API
Interface

Propel\Runtime\Connection\SqlConnectionInterface

interface SqlConnectionInterface implements ConnectionInterface

Interface for Propel Connection object.

Based on the PDO interface.

Methods

setName(string $name)

from ConnectionInterface
string getName()

from ConnectionInterface
boolean beginTransaction()

Turns off autocommit mode.

from ConnectionInterface
boolean commit()

Commits a transaction.

from ConnectionInterface
boolean rollBack()

Rolls back a transaction.

from ConnectionInterface
bool inTransaction()

Checks if inside a transaction.

from ConnectionInterface
mixed getAttribute(string $attribute)

Retrieve a database connection attribute.

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

Set an attribute.

from ConnectionInterface
string lastInsertId(string $name = null)

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

from ConnectionInterface
DataFetcherInterface getSingleDataFetcher($data $data)

from ConnectionInterface
DataFetcherInterface getDataFetcher($data $data)

from ConnectionInterface
int exec(string $statement)

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

StatementInterface|bool prepare(string $statement, array $driver_options = array())

Prepares a statement for execution and returns a statement object.

DataFetcherInterface query(string $statement)

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

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

Quotes a string for use in a query.

Details

in ConnectionInterface at line 25
public setName(string $name)

Parameters

string $name The datasource name associated to this connection

in ConnectionInterface at line 30
public string getName()

Return Value

string The datasource name associated to this connection

in ConnectionInterface at line 43
public boolean beginTransaction()

Turns off autocommit mode.

While autocommit mode is turned off, changes made to the database via
the Connection object instance are not committed until you end the
transaction by calling Connection::commit().
Calling Connection::rollBack() will roll back all changes to the database
and return the connection to autocommit mode.

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionInterface at line 53
public boolean commit()

Commits a transaction.

commit() returns the database connection to autocommit mode until the
next call to connection::beginTransaction() starts a new transaction.

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionInterface at line 65
public boolean rollBack()

Rolls back a transaction.

Rolls back the current transaction, as initiated by beginTransaction().
It is an error to call this method if no transaction is active.
If the database was set to autocommit mode, this function will restore
autocommit mode after it has rolled back the transaction.

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionInterface at line 72
public bool inTransaction()

Checks if inside a transaction.

Return Value

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

in ConnectionInterface at line 83
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 ConnectionInterface at line 93
public boolean setAttribute(string $attribute, mixed $value)

Set an attribute.

Parameters

string $attribute
mixed $value

Return Value

boolean TRUE on success or FALSE on failure.

in ConnectionInterface at line 112
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 ConnectionInterface at line 119
public DataFetcherInterface getSingleDataFetcher($data $data)

Parameters

$data $data

Return Value

DataFetcherInterface

in ConnectionInterface at line 126
public DataFetcherInterface getDataFetcher($data $data)

Parameters

$data $data

Return Value

DataFetcherInterface

at line 32
public int exec(string $statement)

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

Parameters

string $statement The SQL statement to prepare and execute. Data inside the query should be properly escaped.

Return Value

int The number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, returns 0.

at line 53
public StatementInterface|bool prepare(string $statement, array $driver_options = array())

Prepares a statement for execution and returns a statement object.

Prepares an SQL statement to be executed by the Statement::execute() method.
The SQL statement can contain zero or more named (:name) or question mark (?)
parameter markers for which real values will be substituted when the statement
is executed. You cannot use both named and question mark parameter markers
within the same SQL statement; pick one or the other parameter style. Use
these parameters to bind any user-input, do not include the user-input
directly in the query.

Parameters

string $statement This must be a valid SQL statement for the target database server.
array $driver_options

Return Value

StatementInterface|bool A Statement object if the database server successfully prepares, FALSE otherwise.

Exceptions

ConnectionException depending on error handling.

at line 64
public DataFetcherInterface query(string $statement)

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

Parameters

string $statement The SQL statement to prepare and execute. Data inside the query should be properly escaped.

Return Value

DataFetcherInterface

Exceptions

ConnectionException depending on error handling.

at line 81
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.