Propel API
Class

DBMySQL

class DBMySQL extends DBAdapter

This is used in order to connect to a MySQL database.

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.

from DBAdapter
array prepareParams(array $params)

Prepare connection parameters.

initConnection(PDO $con, array $settings)

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

from DBAdapter
setCharset(PDO $con, string $charset)

Sets the character encoding using SQL standard SET NAMES statement.

from DBAdapter
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).

from DBAdapter
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.

from DBAdapter
string concatString(string $s1, string $s2)

Returns SQL which concatenates the second string to the first.

string subString(string $s, integer $pos, integer $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)

string quoteIdentifierTable(string $table)

boolean isGetIdBeforeInsert()

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

from DBAdapter
boolean isGetIdAfterInsert()

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

from DBAdapter
mixed getId(PDO $con, string $name = null)

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

from DBAdapter
string formatTemporalValue(mixed $value, mixed $type)

Formats a temporal value brefore binding, given a ColumnMap object.

from DBAdapter
string getTimestampFormatter()

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

from DBAdapter
string getDateFormatter()

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

from DBAdapter
string getTimeFormatter()

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

from DBAdapter
boolean useQuoteIdentifier()

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

Allows manipulation of the query string before PDOStatement is instantiated.

from DBAdapter
applyLimit(string $sql, integer $offset, integer $limit)

string random(string $seed = null)

string getDeleteFromClause(Criteria $criteria, string $tableName)

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

from DBAdapter
string createSelectSqlPart(Criteria $criteria, array $fromClause, boolean $aliasAll = false)

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

from DBAdapter
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 Moved from BasePeer to DBAdapter and turned from static to non static

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

Binds values in a prepared statement.

from DBAdapter
boolean bindValue(PDOStatement $stmt, string $parameter, mixed $value, ColumnMap $cMap, null|integer $position = null)

lockTable(PDO $con, string $table)

Locks the specified table.

unlockTable(PDO $con, string $table)

Unlocks the specified table.

Details

in DBAdapter 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 208
public array prepareParams(array $params)

Prepare connection parameters.

See: http://www.propelorm.org/ticket/1360

Parameters

array $params

Return Value

array

in DBAdapter at line 100
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()

in DBAdapter at line 125
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 PDO connection instance.
string $charset The $string charset encoding.

See also

initConnection()

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

in DBAdapter at line 145
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 40
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.

in DBAdapter at line 167
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 53
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 67
public string subString(string $s, integer $pos, integer $len)

Returns SQL which extracts a substring.

Parameters

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

Return Value

string

at line 78
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 116
public string quoteIdentifier(string $text)

Parameters

string $text

Return Value

string

See also

DBAdapter::quoteIdentifier()

at line 127
public string quoteIdentifierTable(string $table)

Parameters

string $table

Return Value

string

See also

DBAdapter::quoteIdentifierTable()

in DBAdapter at line 239
public boolean isGetIdBeforeInsert()

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

Return Value

boolean

in DBAdapter at line 249
public boolean isGetIdAfterInsert()

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

Return Value

boolean

in DBAdapter at line 264
public mixed getId(PDO $con, string $name = null)

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

Warning: duplicates logic from DefaultPlatform::getIdentifierPhp().
Any code modification here must be ported there.

Parameters

PDO $con
string $name

Return Value

mixed

in DBAdapter at line 277
public string formatTemporalValue(mixed $value, mixed $type)

Formats a temporal value brefore binding, given a ColumnMap object.

Parameters

mixed $value The temporal value
mixed $type PropelColumnTypes constant, or ColumnMap object

Return Value

string The formatted temporal value

in DBAdapter at line 306
public string getTimestampFormatter()

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

Return Value

string

in DBAdapter at line 316
public string getDateFormatter()

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

Return Value

string

in DBAdapter at line 326
public string getTimeFormatter()

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

Return Value

string

at line 138
public boolean useQuoteIdentifier()

Return Value

boolean

See also

DBAdapter::useQuoteIdentifier()

in DBAdapter at line 355
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 150
public applyLimit(string $sql, integer $offset, integer $limit)

Parameters

string $sql
integer $offset
integer $limit

See also

DBAdapter::applyLimit()

at line 165
public string random(string $seed = null)

Parameters

string $seed

Return Value

string

See also

DBAdapter::random()

in DBAdapter at line 383
public string getDeleteFromClause(Criteria $criteria, string $tableName)

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

Parameters

Criteria $criteria
string $tableName

Return Value

string

in DBAdapter at line 414
public string createSelectSqlPart(Criteria $criteria, array $fromClause, boolean $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
array $fromClause
boolean $aliasAll

Return Value

string

in DBAdapter at line 486
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 Moved from BasePeer to DBAdapter and turned from static to non static

Parameters

Criteria $criteria

Return Value

Criteria The input, with Select columns replaced by aliases

See also

http://propel.phpdb.org/trac/ticket/795

in DBAdapter at line 536
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 181
public boolean bindValue(PDOStatement $stmt, string $parameter, mixed $value, ColumnMap $cMap, null|integer $position = null)

Parameters

PDOStatement $stmt
string $parameter
mixed $value
ColumnMap $cMap
null|integer $position

Return Value

boolean

See also

DBAdapter::bindValue()

at line 92
public lockTable(PDO $con, string $table)

Locks the specified table.

Parameters

PDO $con The Propel connection to use.
string $table The name of the table to lock.

Exceptions

PDOException No Statement could be created or executed.

at line 105
public unlockTable(PDO $con, string $table)

Unlocks the specified table.

Parameters

PDO $con The PDO connection to use.
string $table The name of the table to unlock.

Exceptions

PDOException No Statement could be created or executed.