Source for file DBAdapter.php
Documentation is available at DBAdapter.php
* $Id: DBAdapter.php 563 2007-02-01 09:45:55Z heltem $
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
* 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 Creole
* 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
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Jon S. Stevens <jon@latchkey.com> (Torque)
* @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 563 $
* @package propel.adapter
const ID_METHOD_NONE = 0;
const ID_METHOD_AUTOINCREMENT = 1;
const ID_METHOD_SEQUENCE = 2;
* Creole driver to Propel adapter map.
private static $adapters = array(
* Creates a new instance of the database adapter associated
* with the specified Creole driver.
* @param string $driver The name of the Propel/Creole driver to
* create a new adapter instance for or a shorter form adapter key.
* @return DBAdapter An instance of a Propel database adapter.
* @throws PropelException if the adapter could not be instantiated.
public static function factory($driver) {
$adapterClass = isset (self::$adapters[$driver]) ? self::$adapters[$driver] : null;
if ($adapterClass !== null) {
$a = new $adapterClass();
throw new PropelException("Unsupported Propel driver: " . $driver . ": Check your configuration file");
* This method is called after a connection was created to run necessary
* post-initialization queries or code.
* This base method runs queries specified using the "query" setting.
* @param PDO A PDO connection instance.
* @param array An array of settings.
if (isset ($settings['queries']) && is_array($settings['queries'])) {
foreach ($settings['queries'] as $queries) {
foreach ((array) $queries as $query) {
* This method is used to ignore case.
* @param string The string to transform to upper case.
* @return string The upper case string.
* Returns the character used to indicate the beginning and end of
* a piece of text used in a SQL statement (generally a single
* @return string The text delimeter.
* This method is used to ignore case.
* @param string $in The string whose case to ignore.
* @return string The string in a case that can be ignored.
* 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
* @param string $in The string whose case to ignore.
* @return string The string in a case that can be ignored.
* Returns SQL which concatenates the second string to the first.
* @param string String to concatenate.
* @param string String to append.
* Returns SQL which extracts a substring.
* @param string String to extract from.
* @param int Offset to start from.
* @param int Number of characters to extract.
public abstract function subString($s, $pos, $len);
* Returns SQL which calculates the length (in chars) of a string.
* @param string String to calculate length of.
* Quotes database objec identifiers (table names, col names, sequences, etc.).
* @param string $text The identifier to quote.
* @return string The quoted identifier.
return '"' . $text . '"';
* Returns the native ID method for this RDBMS.
* @return int one of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT.
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
* Gets the generated ID (either last ID for autoincrement or next sequence ID).
public function getId(PDO $con, $name = null)
return $con->lastInsertId($name);
* Returns timestamp formatter string for use in date() function.
* Returns date formatter string for use in date() function.
* Returns time formatter string for use in date() function.
* Should Column-Names get identifiers for inserts or updates.
* By default false is returned -> backwards compability.
* it`s a workaround...!!!
* @todo should be abstract
* Modifies the passed-in SQL to add LIMIT and/or OFFSET.
public abstract function applyLimit(&$sql, $offset, $limit);
public abstract function random($seed= NULL);
|