Propel API
Class

DBAdapter

abstract class DBAdapter

DBAdapter</code> defines the interface for a Propel database adapter.

<p>Support for new databases is added by subclassing
<code>DBAdapter</code> and implementing its abstract interface, and by
registering the new database adapter and corresponding Propel
driver in the private adapters map (array) in this class.</p>

<p>The Propel database adapters exist to present a uniform
interface to database access across all available databases. Once
the necessary adapters have been written and configured,
transparent swapping of databases is theoretically supported with
<i>zero code change</i> and minimal configuration file
modifications.</p>

Constants

ID_METHOD_NONE

ID_METHOD_AUTOINCREMENT

ID_METHOD_SEQUENCE

Methods

static DBAdapter factory(string $driver)

Creates a new instance of the database adapter associated with the specified Propel driver.

initConnection(PDO $con, array $settings)

This method is called after a connection was created to run necessary post-initialization queries or code.

setCharset(PDO $con, string $charset)

Sets the character encoding using SQL standard SET NAMES statement.

string toUpperCase(string $in)

This method is used to ignore case.

string getStringDelimiter()

Returns the character used to indicate the beginning and end of a piece of text used in a SQL statement (generally a single quote).

string ignoreCase(string $in)

This method is used to ignore case.

string ignoreCaseInOrderBy(string $in)

This method is used to ignore case in an ORDER BY clause.

string concatString(string $s1, string $s2)

Returns SQL which concatenates the second string to the first.

string subString(string $s, int $pos, int $len)

Returns SQL which extracts a substring.

string strLength(string $s)

Returns SQL which calculates the length (in chars) of a string.

string quoteIdentifier(string $text)

Quotes database objec identifiers (table names, col names, sequences, etc.).

string quoteIdentifierTable(string $table)

Quotes a database table which could have space seperating it from an alias, both should be identified seperately This doesn't take care of dots which separate schema names from table names.

boolean isGetIdBeforeInsert()

Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.

boolean isGetIdAfterInsert()

Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.

mixed getId(PDO $con, $name = null)

Gets the generated ID (either last ID for autoincrement or next sequence ID).

string getTimestampFormatter()

Returns timestamp formatter string for use in date() function.

string getDateFormatter()

Returns date formatter string for use in date() function.

string getTimeFormatter()

Returns time formatter string for use in date() function.

boolean useQuoteIdentifier()

Should Column-Names get identifiers for inserts or updates.

cleanupSQL(string $sql, array $params, Criteria $values, DatabaseMap $dbMap)

Allows manipulation of the query string before PDOStatement is instantiated.

applyLimit($sql, $offset, $limit)

Modifies the passed-in SQL to add LIMIT and/or OFFSET.

random(mixed $seed = null)

Gets the SQL string that this adapter uses for getting a random number.

string getDeleteFromClause($criteria, $tableName)

Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.

createSelectSqlPart(Criteria $criteria, $fromClause, $aliasAll = false)

Builds the SELECT part of a SQL statement based on a Criteria taking into account select columns and 'as' columns (i.e.

Criteria turnSelectColumnsToAliases(Criteria $criteria)

Ensures uniqueness of select column names by turning them all into aliases This is necessary for queries on more than one table when the tables share a column name

bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap)

Binds values in a prepared statement.

Boolean bindValue(PDOStatement $stmt, string $parameter, mixed $value, ColumnMap $cMap)

Binds a value to a positioned parameted in a statement, given a ColumnMap object to infer the binding type.

Details

at line 65
static public DBAdapter factory(string $driver)

Creates a new instance of the database adapter associated with the specified Propel driver.

Parameters

string $driver The name of the Propel driver to create a new adapter instance for or a shorter form adapter key.

Return Value

DBAdapter An instance of a Propel database adapter.

Exceptions

PropelException if the adapter could not be instantiated.

at line 88
public initConnection(PDO $con, array $settings)

This method is called after a connection was created to run necessary post-initialization queries or code.

If a charset was specified, this will be set before any other queries
are executed.

This base method runs queries specified using the "query" setting.

Parameters

PDO $con A PDO connection instance.
array $settings An array of settings.

See also

setCharset()

at line 112
public setCharset(PDO $con, string $charset)

Sets the character encoding using SQL standard SET NAMES statement.

This method is invoked from the default initConnection() method and must
be overridden for an RDMBS which does _not_ support this SQL standard.

Parameters

PDO $con A PDO connection instance.
string $charset The charset encoding.

See also

initConnection()

at line 123
abstract public string toUpperCase(string $in)

This method is used to ignore case.

Parameters

string $in The string to transform to upper case.

Return Value

string The upper case string.

at line 132
public string getStringDelimiter()

Returns the character used to indicate the beginning and end of a piece of text used in a SQL statement (generally a single quote).

Return Value

string The text delimeter.

at line 143
abstract public string ignoreCase(string $in)

This method is used to ignore case.

Parameters

string $in The string whose case to ignore.

Return Value

string The string in a case that can be ignored.

at line 154
public string ignoreCaseInOrderBy(string $in)

This method is used to ignore case in an ORDER BY clause.

Usually it is the same as ignoreCase, but some databases
(Interbase for example) does not use the same SQL in ORDER BY
and other clauses.

Parameters

string $in The string whose case to ignore.

Return Value

string The string in a case that can be ignored.

at line 166
abstract public string concatString(string $s1, string $s2)

Returns SQL which concatenates the second string to the first.

Parameters

string $s1 String to concatenate.
string $s2 String to append.

Return Value

string

at line 176
abstract public string subString(string $s, int $pos, int $len)

Returns SQL which extracts a substring.

Parameters

string $s String to extract from.
int $pos Offset to start from.
int $len Number of characters to extract.

Return Value

string

at line 184
abstract public string strLength(string $s)

Returns SQL which calculates the length (in chars) of a string.

Parameters

string $s String to calculate length of.

Return Value

string

at line 192
public string quoteIdentifier(string $text)

Quotes database objec identifiers (table names, col names, sequences, etc.).

Parameters

string $text The identifier to quote.

Return Value

string The quoted identifier.

at line 205
public string quoteIdentifierTable(string $table)

Quotes a database table which could have space seperating it from an alias, both should be identified seperately This doesn't take care of dots which separate schema names from table names.

Adapters for RDBMs which support
schemas have to implement that in the platform-specific way.

Parameters

string $table The table name to quo

Return Value

string The quoted table name

at line 222
public boolean isGetIdBeforeInsert()

Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.

Return Value

boolean

at line 231
public boolean isGetIdAfterInsert()

Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.

Return Value

boolean

at line 240
public mixed getId(PDO $con, $name = null)

Gets the generated ID (either last ID for autoincrement or next sequence ID).

Parameters

PDO $con
$name

Return Value

mixed

at line 276
public string getTimestampFormatter()

Returns timestamp formatter string for use in date() function.

Return Value

string

at line 285
public string getDateFormatter()

Returns date formatter string for use in date() function.

Return Value

string

at line 294
public string getTimeFormatter()

Returns time formatter string for use in date() function.

Return Value

string

at line 309
public boolean useQuoteIdentifier()

Should Column-Names get identifiers for inserts or updates.

By default false is returned -> backwards compability.

it`s a workaround...!!!

Return Value

boolean

at line 322
public cleanupSQL(string $sql, array $params, Criteria $values, DatabaseMap $dbMap)

Allows manipulation of the query string before PDOStatement is instantiated.

Parameters

string $sql The sql statement
array $params array('column' => ..., 'table' => ..., 'value' => ...)
Criteria $values
DatabaseMap $dbMap

at line 329
abstract public applyLimit($sql, $offset, $limit)

Modifies the passed-in SQL to add LIMIT and/or OFFSET.

Parameters

$sql
$offset
$limit

at line 336
abstract public random(mixed $seed = null)

Gets the SQL string that this adapter uses for getting a random number.

Parameters

mixed $seed (optional) seed value for databases that support this

at line 343
public string getDeleteFromClause($criteria, $tableName)

Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.

Parameters

$criteria
$tableName

Return Value

string

at line 368
public createSelectSqlPart(Criteria $criteria, $fromClause, $aliasAll = false)

Builds the SELECT part of a SQL statement based on a Criteria taking into account select columns and 'as' columns (i.e.

columns aliases)
Move from BasePeer to DBAdapter and turn from static to non static

Parameters

Criteria $criteria
$fromClause
$aliasAll

at line 440
public Criteria turnSelectColumnsToAliases(Criteria $criteria)

Ensures uniqueness of select column names by turning them all into aliases This is necessary for queries on more than one table when the tables share a column name

Parameters

Criteria $criteria

Return Value

Criteria The input, with Select columns replaced by aliases

See also

http://propel.phpdb.org/trac/ticket/795 Move from BasePeer to DBAdapter and turn from static to non static

at line 490
public bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap)

Binds values in a prepared statement.

This method is designed to work with the BasePeer::createSelectSql() method, which creates
both the SELECT SQL statement and populates a passed-in array of parameter
values that should be substituted.

<code>
$db = Propel::getDB($criteria->getDbName());
$sql = BasePeer::createSelectSql($criteria, $params);
$stmt = $con->prepare($sql);
$params = array();
$db->populateStmtValues($stmt, $params, Propel::getDatabaseMap($critera->getDbName()));
$stmt->execute();
</code>

Parameters

PDOStatement $stmt
array $params array('column' => ..., 'table' => ..., 'value' => ...)
DatabaseMap $dbMap

at line 521
public Boolean bindValue(PDOStatement $stmt, string $parameter, mixed $value, ColumnMap $cMap)

Binds a value to a positioned parameted in a statement, given a ColumnMap object to infer the binding type.

Parameters

PDOStatement $stmt The statement to bind
string $parameter Parameter identifier
mixed $value The value to bind
ColumnMap $cMap The ColumnMap of the column to bind

Return Value

Boolean TRUE on success or FALSE on failure.