CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,297 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* 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>
*
* @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: 1612 $
* @package propel.runtime.adapter
*/
abstract class DBAdapter
{
const ID_METHOD_NONE = 0;
const ID_METHOD_AUTOINCREMENT = 1;
const ID_METHOD_SEQUENCE = 2;
/**
* Propel driver to Propel adapter map.
* @var array
*/
private static $adapters = array(
'mysql' => 'DBMySQL',
'mysqli' => 'DBMySQLi',
'mssql' => 'DBMSSQL',
'dblib' => 'DBMSSQL',
'sybase' => 'DBSybase',
'oracle' => 'DBOracle',
'oci' => 'DBOracle',
'pgsql' => 'DBPostgres',
'sqlite' => 'DBSQLite',
'' => 'DBNone',
);
/**
* Creates a new instance of the database adapter associated
* with the specified Propel driver.
*
* @param string $driver The name of the Propel 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();
return $a;
} else {
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.
*
* 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.
*
* @param PDO A PDO connection instance.
* @param array An array of settings.
* @see setCharset()
*/
public function initConnection(PDO $con, array $settings)
{
if (isset($settings['charset']['value'])) {
$this->setCharset($con, $settings['charset']['value']);
}
if (isset($settings['queries']) && is_array($settings['queries'])) {
foreach ($settings['queries'] as $queries) {
foreach ((array)$queries as $query) {
$con->exec($query);
}
}
}
}
/**
* 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.
*
* @param PDO A PDO connection instance.
* @param string The charset encoding.
* @see initConnection()
*/
public function setCharset(PDO $con, $charset)
{
$con->exec("SET NAMES '" . $charset . "'");
}
/**
* This method is used to ignore case.
*
* @param string The string to transform to upper case.
* @return string The upper case string.
*/
public abstract function toUpperCase($in);
/**
* 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 string The text delimeter.
*/
public function getStringDelimiter()
{
return '\'';
}
/**
* 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.
*/
public abstract function ignoreCase($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.
*
* @param string $in The string whose case to ignore.
* @return string The string in a case that can be ignored.
*/
public function ignoreCaseInOrderBy($in)
{
return $this->ignoreCase($in);
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public abstract function concatString($s1, $s2);
/**
* 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.
* @return string
*/
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.
* @return string
*/
public abstract function strLength($s);
/**
* Quotes database objec identifiers (table names, col names, sequences, etc.).
* @param string $text The identifier to quote.
* @return string The quoted identifier.
*/
public function quoteIdentifier($text)
{
return '"' . $text . '"';
}
/**
* Quotes a database table which could have space seperating it from an alias, both should be identified seperately
* @param string $table The table name to quo
* @return string The quoted table name
**/
public function quoteIdentifierTable($table) {
return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table) ) );
}
/**
* Returns the native ID method for this RDBMS.
* @return int one of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT.
*/
protected function getIdMethod()
{
return DBAdapter::ID_METHOD_AUTOINCREMENT;
}
/**
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
* @return boolean
*/
public function isGetIdBeforeInsert()
{
return ($this->getIdMethod() === DBAdapter::ID_METHOD_SEQUENCE);
}
/**
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
* @return boolean
*/
public function isGetIdAfterInsert()
{
return ($this->getIdMethod() === DBAdapter::ID_METHOD_AUTOINCREMENT);
}
/**
* Gets the generated ID (either last ID for autoincrement or next sequence ID).
* @return mixed
*/
public function getId(PDO $con, $name = null)
{
return $con->lastInsertId($name);
}
/**
* Returns timestamp formatter string for use in date() function.
* @return string
*/
public function getTimestampFormatter()
{
return "Y-m-d H:i:s";
}
/**
* Returns date formatter string for use in date() function.
* @return string
*/
public function getDateFormatter()
{
return "Y-m-d";
}
/**
* Returns time formatter string for use in date() function.
* @return string
*/
public function getTimeFormatter()
{
return "H:i:s";
}
/**
* Should Column-Names get identifiers for inserts or updates.
* By default false is returned -> backwards compability.
*
* it`s a workaround...!!!
*
* @todo should be abstract
* @return boolean
* @deprecated
*/
public function useQuoteIdentifier()
{
return false;
}
/**
* Modifies the passed-in SQL to add LIMIT and/or OFFSET.
*/
public abstract function applyLimit(&$sql, $offset, $limit);
/**
* Gets the SQL string that this adapter uses for getting a random number.
*
* @param mixed $seed (optional) seed value for databases that support this
*/
public abstract function random($seed = null);
}

View file

@ -0,0 +1,215 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* This is used to connect to a MSSQL database.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @version $Revision: 1700 $
* @package propel.runtime.adapter
*/
class DBMSSQL extends DBAdapter
{
/**
* This method is used to ignore case.
*
* @param in The string to transform to upper case.
* @return The upper case string.
*/
public function toUpperCase($in)
{
return $this->ignoreCase($in);
}
/**
* This method is used to ignore case.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
return 'UPPER(' . $in . ')';
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return '(' . $s1 . ' + ' . $s2 . ')';
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return 'SUBSTRING(' . $s . ', ' . $pos . ', ' . $len . ')';
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return 'LEN(' . $s . ')';
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
/**
* @see DBAdapter::random()
*/
public function random($seed = null)
{
return 'RAND(' . ((int)$seed) . ')';
}
/**
* Simulated Limit/Offset
* This rewrites the $sql query to apply the offset and limit.
* some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform
* @see DBAdapter::applyLimit()
* @author Benjamin Runnels <kraven@kraven.org>
*/
public function applyLimit(&$sql, $offset, $limit)
{
// make sure offset and limit are numeric
if(! is_numeric($offset) || ! is_numeric($limit))
{
throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3');
}
//split the select and from clauses out of the original query
$selectSegment = array();
$selectText = 'SELECT ';
if (preg_match('/\Aselect(\s+)distinct/i', $sql)) {
$selectText .= 'DISTINCT ';
}
preg_match('/\Aselect(.*)from(.*)/si', $sql, $selectSegment);
if(count($selectSegment) == 3) {
$selectStatement = trim($selectSegment[1]);
$fromStatement = trim($selectSegment[2]);
} else {
throw new Exception('DBMSSQL::applyLimit() could not locate the select statement at the start of the query.');
}
// if we're starting at offset 0 then theres no need to simulate limit,
// just grab the top $limit number of rows
if($offset == 0) {
$sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement;
return;
}
//get the ORDER BY clause if present
$orderStatement = stristr($fromStatement, 'ORDER BY');
$orders = '';
if($orderStatement !== false) {
//remove order statement from the from statement
$fromStatement = trim(str_replace($orderStatement, '', $fromStatement));
$order = str_ireplace('ORDER BY', '', $orderStatement);
$orders = explode(',', $order);
for($i = 0; $i < count($orders); $i ++) {
$orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array(
'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC',
'key' => $i
);
}
}
//setup inner and outer select selects
$innerSelect = '';
$outerSelect = '';
foreach(explode(', ', $selectStatement) as $selCol) {
$selColArr = explode(' ', $selCol);
$selColCount = count($selColArr) - 1;
//make sure the current column isn't * or an aggregate
if($selColArr[0] != '*' && ! strstr($selColArr[0], '(')) {
if(isset($orderArr[$selColArr[0]])) {
$orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort'];
}
//use the alias if one was present otherwise use the column name
$alias = (! stristr($selCol, ' AS ')) ? $this->quoteIdentifier($selColArr[0]) : $this->quoteIdentifier($selColArr[$selColCount]);
//save the first non-aggregate column for use in ROW_NUMBER() if required
if(! isset($firstColumnOrderStatement)) {
$firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0];
}
//add an alias to the inner select so all columns will be unique
$innerSelect .= $selColArr[0] . ' AS ' . $alias . ', ';
$outerSelect .= $alias . ', ';
} else {
//agregate columns must always have an alias clause
if(! stristr($selCol, ' AS ')) {
throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause');
}
//aggregate column alias can't be used as the count column you must use the entire aggregate statement
if(isset($orderArr[$selColArr[$selColCount]])) {
$orders[$orderArr[$selColArr[$selColCount]]['key']] = str_replace($selColArr[$selColCount - 1] . ' ' . $selColArr[$selColCount], '', $selCol) . $orderArr[$selColArr[$selColCount]]['sort'];
}
//quote the alias
$alias = $this->quoteIdentifier($selColArr[$selColCount]);
$innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', ';
$outerSelect .= $alias . ', ';
}
}
if(is_array($orders)) {
$orderStatement = 'ORDER BY ' . implode(', ', $orders);
} else {
//use the first non aggregate column in our select statement if no ORDER BY clause present
if(isset($firstColumnOrderStatement)) {
$orderStatement = $firstColumnOrderStatement;
} else {
throw new Exception('DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()');
}
}
//substring the select strings to get rid of the last comma and add our FROM and SELECT clauses
$innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS RowNumber, ' . substr($innerSelect, 0, - 2) . ' FROM';
//outer select can't use * because of the RowNumber column
$outerSelect = 'SELECT ' . substr($outerSelect, 0, - 2) . ' FROM';
//ROW_NUMBER() starts at 1 not 0
$sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset);
return;
}
}

View file

@ -0,0 +1,145 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* This is used in order to connect to a MySQL database.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Jon S. Stevens <jon@clearink.com> (Torque)
* @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 1612 $
* @package propel.runtime.adapter
*/
class DBMySQL extends DBAdapter
{
/**
* This method is used to ignore case.
*
* @param in The string to transform to upper case.
* @return The upper case string.
*/
public function toUpperCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* This method is used to ignore case.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return "CONCAT($s1, $s2)";
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return "SUBSTRING($s, $pos, $len)";
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return "CHAR_LENGTH($s)";
}
/**
* Locks the specified table.
*
* @param Connection $con The Propel connection to use.
* @param string $table The name of the table to lock.
* @throws PDOException No Statement could be created or
* executed.
*/
public function lockTable(PDO $con, $table)
{
$con->exec("LOCK TABLE " . $table . " WRITE");
}
/**
* Unlocks the specified table.
*
* @param PDO $con The PDO connection to use.
* @param string $table The name of the table to unlock.
* @throws PDOException No Statement could be created or
* executed.
*/
public function unlockTable(PDO $con, $table)
{
$statement = $con->exec("UNLOCK TABLES");
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '`' . $text . '`';
}
/**
* @see DBAdapter::useQuoteIdentifier()
*/
public function useQuoteIdentifier()
{
return true;
}
/**
* @see DBAdapter::applyLimit()
*/
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
$sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit;
} else if ( $offset > 0 ) {
$sql .= " LIMIT " . $offset . ", 18446744073709551615";
}
}
/**
* @see DBAdapter::random()
*/
public function random($seed = null)
{
return 'rand('.((int) $seed).')';
}
}

View file

@ -0,0 +1,104 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* This adapter is used when you do not have a database installed.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Jon S. Stevens <jon@clearink.com> (Torque)
* @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
* @version $Revision: 1612 $
* @package propel.runtime.adapter
*/
class DBNone extends DBAdapter
{
/**
* @see DBAdapter::initConnection()
*/
public function initConnection(PDO $con, array $settings)
{
}
/**
* This method is used to ignore case.
*
* @param in The string to transform to upper case.
* @return The upper case string.
*/
public function toUpperCase($in)
{
return $in;
}
/**
* This method is used to ignore case.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
return $in;
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return ($s1 . $s2);
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return substr($s, $pos, $len);
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return strlen($s);
}
/**
* Modifies the passed-in SQL to add LIMIT and/or OFFSET.
*/
public function applyLimit(&$sql, $offset, $limit)
{
}
/**
* Gets the SQL string that this adapter uses for getting a random number.
*
* @param mixed $seed (optional) seed value for databases that support this
*/
public function random($seed = null)
{
}
}

View file

@ -0,0 +1,150 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* Oracle adapter.
*
* @author David Giffin <david@giffin.org> (Propel)
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Jon S. Stevens <jon@clearink.com> (Torque)
* @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
* @author Bill Schneider <bschneider@vecna.com> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 1669 $
* @package propel.runtime.adapter
*/
class DBOracle extends DBAdapter
{
/**
* This method is called after a connection was created to run necessary
* post-initialization queries or code.
* Removes the charset query and adds the date queries
*
* @param PDO A PDO connection instance.
* @see parent::initConnection()
*/
public function initConnection(PDO $con, array $settings)
{
$con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
$con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'");
if (isset($settings['queries']) && is_array($settings['queries'])) {
foreach ($settings['queries'] as $queries) {
foreach ((array)$queries as $query) {
$con->exec($query);
}
}
}
}
/**
* This method is used to ignore case.
*
* @param string $in The string to transform to upper case.
* @return string The upper case string.
*/
public function toUpperCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* 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.
*/
public function ignoreCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return "CONCAT($s1, $s2)";
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return "SUBSTR($s, $pos, $len)";
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return "LENGTH($s)";
}
/**
* @see DBAdapter::applyLimit()
*/
public function applyLimit(&$sql, $offset, $limit, $criteria = null)
{
if (BasePeer::needsSelectAliases($criteria)) {
$selectSql = BasePeer::createSelectSqlPart($criteria, $params, true);
$sql = $selectSql . substr($sql, strpos('FROM', $sql));
}
$sql = 'SELECT B.* FROM ('
. 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A '
. ') B WHERE ';
if ( $offset > 0 ) {
$sql .= ' B.PROPEL_ROWNUM > ' . $offset;
if ( $limit > 0 ) {
$sql .= ' AND B.PROPEL_ROWNUM <= ' . ( $offset + $limit );
}
} else {
$sql .= ' B.PROPEL_ROWNUM <= ' . $limit;
}
}
protected function getIdMethod()
{
return DBAdapter::ID_METHOD_SEQUENCE;
}
public function getId(PDO $con, $name = null)
{
if ($name === null) {
throw new PropelException("Unable to fetch next sequence ID without sequence name.");
}
$stmt = $con->query("SELECT " . $name . ".nextval FROM dual");
$row = $stmt->fetch(PDO::FETCH_NUM);
return $row[0];
}
public function random($seed=NULL)
{
return 'dbms_random.value';
}
}

View file

@ -0,0 +1,141 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* This is used to connect to PostgresQL databases.
*
* <a href="http://www.pgsql.org">http://www.pgsql.org</a>
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Hakan Tandogan <hakan42@gmx.de> (Torque)
* @version $Revision: 1612 $
* @package propel.runtime.adapter
*/
class DBPostgres extends DBAdapter
{
/**
* This method is used to ignore case.
*
* @param string $in The string to transform to upper case.
* @return string The upper case string.
*/
public function toUpperCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* This method is used to ignore case.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
return "UPPER(" . $in . ")";
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return "($s1 || $s2)";
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")";
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return "char_length($s)";
}
/**
* @see DBAdapter::getIdMethod()
*/
protected function getIdMethod()
{
return DBAdapter::ID_METHOD_SEQUENCE;
}
/**
* Gets ID for specified sequence name.
*/
public function getId(PDO $con, $name = null)
{
if ($name === null) {
throw new PropelException("Unable to fetch next sequence ID without sequence name.");
}
$stmt = $con->query("SELECT nextval(".$con->quote($name).")");
$row = $stmt->fetch(PDO::FETCH_NUM);
return $row[0];
}
/**
* Returns timestamp formatter string for use in date() function.
* @return string
*/
public function getTimestampFormatter()
{
return "Y-m-d H:i:s O";
}
/**
* Returns timestamp formatter string for use in date() function.
* @return string
*/
public function getTimeFormatter()
{
return "H:i:s O";
}
/**
* @see DBAdapter::applyLimit()
*/
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
$sql .= " LIMIT ".$limit;
}
if ( $offset > 0 ) {
$sql .= " OFFSET ".$offset;
}
}
/**
* @see DBAdapter::random()
*/
public function random($seed=NULL)
{
return 'random()';
}
}

View file

@ -0,0 +1,116 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* This is used in order to connect to a SQLite database.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.runtime.adapter
*/
class DBSQLite extends DBAdapter
{
/**
* For SQLite this method has no effect, since SQLite doesn't support specifying a character
* set (or, another way to look at it, it doesn't require a single character set per DB).
*
* @param PDO A PDO connection instance.
* @param string The charset encoding.
* @throws PropelException If the specified charset doesn't match sqlite_libencoding()
*/
public function setCharset(PDO $con, $charset)
{
}
/**
* This method is used to ignore case.
*
* @param in The string to transform to upper case.
* @return The upper case string.
*/
public function toUpperCase($in)
{
return 'UPPER(' . $in . ')';
}
/**
* This method is used to ignore case.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
return 'UPPER(' . $in . ')';
}
/**
* Returns SQL which concatenates the second string to the first.
*
* @param string String to concatenate.
* @param string String to append.
* @return string
*/
public function concatString($s1, $s2)
{
return "($s1 || $s2)";
}
/**
* 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.
* @return string
*/
public function subString($s, $pos, $len)
{
return "substr($s, $pos, $len)";
}
/**
* Returns SQL which calculates the length (in chars) of a string.
*
* @param string String to calculate length of.
* @return string
*/
public function strLength($s)
{
return "length($s)";
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
/**
* @see DBAdapter::applyLimit()
*/
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
$sql .= " LIMIT " . $limit . ($offset > 0 ? " OFFSET " . $offset : "");
} elseif ( $offset > 0 ) {
$sql .= " LIMIT -1 OFFSET " . $offset;
}
}
public function random($seed=NULL)
{
return 'random()';
}
}

View file

@ -0,0 +1,35 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* MSSQL Server returns datetimes in a format that strtotime doesn't handle so we need to extend DateTime
*
* @package propel.runtime.adapter.MSSQL
*/
class MssqlDateTime extends DateTime
{
public function __construct($datetime='now', DateTimeZone $tz = null)
{
//if the date is bad account for Mssql datetime format
if ($datetime != 'now' && strtotime($datetime) === false)
{
$datetime = substr($datetime,0, -6).substr($datetime,-2);
}
if($tz instanceof DateTimeZone)
{
parent::__construct($datetime,$tz);
}
else
{
parent::__construct($datetime);
}
}
}

View file

@ -0,0 +1,19 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* dblib doesn't support transactions so we need to add a workaround for transactions, last insert ID, and quoting
*
* @package propel.runtime.adapter.MSSQL
*/
class MssqlDebugPDO extends MssqlPropelPDO
{
public $useDebug = true;
}

View file

@ -0,0 +1,132 @@
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
/**
* dblib doesn't support transactions so we need to add a workaround for transactions, last insert ID, and quoting
*
* @package propel.runtime.adapter.MSSQL
*/
class MssqlPropelPDO extends PropelPDO
{
/**
* Begin a transaction.
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
*/
public function beginTransaction()
{
$return = true;
$opcount = $this->getNestedTransactionCount();
if ( $opcount === 0 ) {
$return = self::exec('BEGIN TRANSACTION');
if ($this->useDebug) {
$this->log('Begin transaction', null, __METHOD__);
}
$this->isUncommitable = false;
}
$this->nestedTransactionCount++;
return $return;
}
/**
* Commit a transaction.
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
*/
public function commit()
{
$return = true;
$opcount = $this->getNestedTransactionCount();
if ($opcount > 0) {
if ($opcount === 1) {
if ($this->isUncommitable) {
throw new PropelException('Cannot commit because a nested transaction was rolled back');
} else {
$return = self::exec('COMMIT TRANSACTION');
if ($this->useDebug) {
$this->log('Commit transaction', null, __METHOD__);
}
}
}
$this->nestedTransactionCount--;
}
return $return;
}
/**
* Roll-back a transaction.
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
*/
public function rollBack()
{
$return = true;
$opcount = $this->getNestedTransactionCount();
if ($opcount > 0) {
if ($opcount === 1) {
$return = self::exec('ROLLBACK TRANSACTION');
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
} else {
$this->isUncommitable = true;
}
$this->nestedTransactionCount--;
}
return $return;
}
/**
* Rollback the whole transaction, even if this is a nested rollback
* and reset the nested transaction count to 0.
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
*/
public function forceRollBack()
{
$return = true;
$opcount = $this->getNestedTransactionCount();
if ($opcount > 0) {
// If we're in a transaction, always roll it back
// regardless of nesting level.
$return = self::exec('ROLLBACK TRANSACTION');
// reset nested transaction count to 0 so that we don't
// try to commit (or rollback) the transaction outside this scope.
$this->nestedTransactionCount = 0;
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
}
return $return;
}
public function lastInsertId($seqname = null)
{
$result = self::query('SELECT SCOPE_IDENTITY()');
return (int) $result->fetchColumn();
}
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
public function useQuoteIdentifier()
{
return true;
}
}