initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

586
lib/symfony/vendor/propel/Propel.php vendored Executable file
View File

@ -0,0 +1,586 @@
<?php
/*
* $Id: Propel.php 601 2007-03-07 13:23:12Z hans $
*
* 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>.
*/
include_once 'propel/PropelException.php';
include_once 'propel/adapter/DBAdapter.php';
/**
* Propel's main resource pool and initialization & configuration class.
*
* This static class is used to handle Propel initialization and to maintain all of the
* open database connections and instantiated database maps.
*
* @author Hans Lellelid <hans@xmpl.rg> (Propel)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @author Magn<67>s <20><>r Torfason <magnus@handtolvur.is> (Torque)
* @author Jason van Zyl <jvanzyl@apache.org> (Torque)
* @author Rafal Krzewski <Rafal.Krzewski@e-point.pl> (Torque)
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
* @author Henning P. Schmiedehausen <hps@intermeta.de> (Torque)
* @author Kurt Schrader <kschrader@karmalab.org> (Torque)
* @version $Revision: 601 $
* @package propel
*/
class Propel {
/**
* A constant for <code>default</code>.
*/
const DEFAULT_NAME = "default";
/**
* A constant defining 'System is unusuable' logging level
*/
const LOG_EMERG = 0;
/**
* A constant defining 'Immediate action required' logging level
*/
const LOG_ALERT = 1;
/**
* A constant defining 'Critical conditions' logging level
*/
const LOG_CRIT = 2;
/**
* A constant defining 'Error conditions' logging level
*/
const LOG_ERR = 3;
/**
* A constant defining 'Warning conditions' logging level
*/
const LOG_WARNING = 4;
/**
* A constant defining 'Normal but significant' logging level
*/
const LOG_NOTICE = 5;
/**
* A constant defining 'Informational' logging level
*/
const LOG_INFO = 6;
/**
* A constant defining 'Debug-level messages' logging level
*/
const LOG_DEBUG = 7;
/**
* The Propel version.
*/
const VERSION = '1.2.1';
/**
* The db name that is specified as the default in the property file
*/
private static $defaultDBName;
/**
* The global cache of database maps
*/
private static $dbMaps = array();
/**
* The cache of DB adapter keys
*/
private static $adapterMap;
/**
* The logging category.
*/
private static $category;
/**
* Propel-specific configuration.
*/
private static $configuration;
/**
* flag to set to true once this class has been initialized
*/
private static $isInit = false;
/**
* @var Log
*/
private static $logger = null;
/**
* Store mapbuilder classnames for peers that have been referenced prior
* to Propel being initialized. This can happen if the OM Peer classes are
* included before the Propel::init() method has been called.
*/
private static $mapBuilders = array();
/**
* Cache of established connections (to eliminate overhead).
* @var array
*/
private static $connectionMap = array();
/**
* initialize Propel
* @return void
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function initialize() {
if (self::$configuration === null) {
throw new PropelException("Propel cannot be initialized without "
. "a valid configuration. Please check the log files "
. "for further details.");
}
self::configureLogging();
// Now that we have dealt with processing the log properties
// that may be contained in the configuration we will make the
// configuration consist only of the remaining propel-specific
// properties that are contained in the configuration. First
// look for properties that are in the "propel" namespace.
$originalConf = self::$configuration;
self::$configuration = isset(self::$configuration['propel']) ? self::$configuration['propel'] : null;
if (empty(self::$configuration)) {
// Assume the original configuration already had any
// prefixes stripped.
self::$configuration = $originalConf;
}
// reset the connection map (this should enable runtime changes of connection params)
self::$connectionMap = array();
self::initAdapters(self::$configuration);
self::$isInit = true;
// map builders may be registered w/ Propel before Propel has
// been initialized; in this case they are stored in a static
// var of this class & now can be propertly initialized.
foreach(self::$mapBuilders as $mbClass) {
BasePeer::getMapBuilder($mbClass);
}
// now that the pre-loaded map builders have been propertly initialized
// empty the array.
// any further mapBuilders will be build by the generated MapBuilder classes.
self::$mapBuilders = array();
}
/**
* Setup the adapters needed. An adapter must be defined for each database connection.
* Generally the adapter will be the same as the PEAR phpname; e.g. for MySQL, use the
* 'mysql' adapter.
* @param array $configuration the Configuration representing the properties file
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
private static function initAdapters($configuration) {
self::$adapterMap = array();
$c = isset($configuration['datasources']) ? $configuration['datasources'] : null;
if (!empty($c)) {
try {
foreach($c as $handle => $properties) {
if (is_array($properties) && isset($properties['adapter'])) {
$db = DBAdapter::factory($properties['adapter']);
// register the adapter for this name
self::$adapterMap[$handle] = $db;
}
}
} catch (Exception $e) {
throw new PropelException("Unable to initialize adapters.", $e);
}
} else {
self::log("There were no adapters in the configuration.", self::LOG_WARNING);
}
}
/**
* configure propel
*
* @param string $config Path (absolute or relative to include_path) to config file.
* @return void
* @throws PropelException If configuration file cannot be opened. (E_WARNING probably will also be raised in PHP)
*/
public static function configure($configFile)
{
self::$configuration = include($configFile);
if (self::$configuration === false) {
throw new PropelException("Unable to open configuration file: " . var_export($configFile, true));
}
}
/**
* Initialization of Propel with a properties file.
*
* @param string $c The Propel configuration file path.
* @return void
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function init($c)
{
self::configure($c);
self::initialize();
}
/**
* Determine whether Propel has already been initialized.
*
* @return boolean True if Propel is already initialized.
*/
public static function isInit()
{
return self::$isInit;
}
/**
* Sets the configuration for Propel and all dependencies.
*
* @param array $c the Configuration
* @return void
*/
public static function setConfiguration($c)
{
self::$configuration = $c;
}
/**
* Get the configuration for this component.
*
* @return the Configuration
*/
public static function getConfiguration()
{
return self::$configuration;
}
/**
* Configure the logging for this subsystem.
* The logging system is only configured if there is a 'log'
* section in the passed-in runtime configuration.
* @return void
*/
protected static function configureLogging() {
if (self::$logger === null) {
if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) {
include_once 'Log.php'; // PEAR Log class
$c = self::$configuration['log'];
// array casting handles bug in PHP5b2 where the isset() checks
// below may return true if $c is not an array (e.g. is a string)
$type = isset($c['type']) ? $c['type'] : 'file';
$name = isset($c['name']) ? $c['name'] : './propel.log';
$ident = isset($c['ident']) ? $c['ident'] : 'propel';
$conf = isset($c['conf']) ? $c['conf'] : array();
$level = isset($c['level']) ? $c['level'] : PEAR_LOG_DEBUG;
self::$logger = Log::singleton($type, $name, $ident, $conf, $level);
} // if isset()
}
}
/**
* Override the configured logger.
*
* This is primarily for things like unit tests / debugging where
* you want to change the logger without altering the configuration file.
*
* You can use any logger class that implements the propel.logger.BasicLogger
* interface. This interface is based on PEAR::Log, so you can also simply pass
* a PEAR::Log object to this method.
*
* @param object $logger The new logger to use. ([PEAR] Log or BasicLogger)
* @return void
*/
public static function setLogger($logger)
{
self::$logger = $logger;
}
/**
* Returns true if a logger, for example PEAR::Log, has been configured,
* otherwise false.
*
* @return boolean True if Propel uses logging
*/
public static function hasLogger()
{
return self::$logger !== null;
}
/**
* Get the configured logger.
* @return object Configured log class ([PEAR] Log or BasicLogger).
*/
public static function logger()
{
return self::$logger;
}
/**
* Logs a message
* If a logger has been configured, the logger will be used, otherwrise the
* logging message will be discarded without any further action
*
* @param string $message The message that will be logged.
* @param string $level The logging level.
* @return boolean True if the message was logged successfully or no logger was used.
*/
public static function log($message, $level = self::LOG_DEBUG)
{
if(self::hasLogger())
{
$logger = self::logger();
switch($level)
{
case self::LOG_EMERG:
return $logger->log($message, $level);
case self::LOG_ALERT:
return $logger->alert($message);
case self::LOG_CRIT:
return $logger->crit($message);
case self::LOG_ERR:
return $logger->err($message);
case self::LOG_WARNING:
return $logger->warning($message);
case self::LOG_NOTICE:
return $logger->notice($message);
case self::LOG_INFO:
return $logger->info($message);
default:
return $logger->debug($message);
}
}
return true;
}
/**
* Returns the database map information. Name relates to the name
* of the connection pool to associate with the map.
*
* The database maps are "registered" by the generated map builder classes.
*
* @param string $name The name of the database corresponding to the DatabaseMapto retrieve.
* @return DatabaseMap The named <code>DatabaseMap</code>.
* @throws PropelException - if database map is null or propel was not initialized properly.
*/
public static function getDatabaseMap($name = null) {
if ($name === null) {
$name = self::getDefaultDB();
if ($name === null) {
throw new PropelException("DatabaseMap name was null!");
}
}
// CACHEHOOK - this would be a good place
// to add shared memory caching options (database
// maps should be a pretty safe candidate for shared mem caching)
if (isset(self::$dbMaps[$name])) {
$map = self::$dbMaps[$name];
} else {
$map = self::initDatabaseMap($name);
}
return $map;
}
/**
* Creates and initializes the mape for the named database.
*
* The database maps are "registered" by the generated map builder classes
* by calling this method and then adding the tables, etc. to teh DatabaseMap
* object returned from this method.
*
* @param string $name The name of the database to map.
* @return DatabaseMap The desired map.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
private static function initDatabaseMap($name)
{
$map = new DatabaseMap($name);
self::$dbMaps[$name] = $map;
return $map;
}
/**
* Register a MapBuilder
*
* @param string $className the MapBuilder
*/
public static function registerMapBuilder($className)
{
self::$mapBuilders[] = $className;
}
/**
* Returns the specified property of the given database, or the empty
* string if no value is set for the property.
*
* @param string $db The name of the database whose property to get.
* @param string $prop The name of the property to get.
* @return mixed The property's value.
*/
private static function getDatabaseProperty($db, $prop)
{
return isset(self::$configuration['datasources'][$db][$prop]) ? self::$configuration['datasources'][$db][$prop] : null;
}
/**
*
* @param string $name The database name.
* @return Connection A database connection
* @throws PropelException - if no conneciton params, or SQLException caught when trying to connect.
*/
public static function getConnection($name = null) {
if ($name === null) {
$name = self::getDefaultDB();
}
$con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
if ($con === null) {
$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
if ($dsn === null) {
throw new PropelException("No connection params set for " . $name);
}
include_once 'creole/Creole.php';
// if specified, use custom driver
if (isset(self::$configuration['datasources'][$name]['driver'])) {
Creole::registerDriver($dsn['phptype'], self::$configuration['datasources'][$name]['driver']);
}
try {
$con = Creole::getConnection($dsn);
} catch (SQLException $e) {
throw new PropelException($e);
}
self::$connectionMap[$name] = $con;
}
return $con;
}
/**
* Returns database adapter for a specific connection pool.
*
* @param string $name A database name.
* @return DBAdapter The corresponding database adapter.
* @throws PropelException - if unable to find DBdapter for specified db.
*/
public static function getDB($name = null)
{
if ($name === null) {
$name = self::getDefaultDB();
}
if (!isset(self::$adapterMap[$name])) {
throw new PropelException("Unable to load DBAdapter for database '" . var_export($name, true) . "' (check your runtime properties file!)");
}
return self::$adapterMap[$name];
}
/**
* Returns the name of the default database.
*
* @return string Name of the default DB
*/
public static function getDefaultDB()
{
if (self::$configuration === null) {
return self::DEFAULT_NAME;
} elseif (self::$defaultDBName === null) {
// Determine default database name.
self::$defaultDBName = isset(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME;
}
return self::$defaultDBName;
}
/**
* Include once a file specified in DOT notation and reutrn unqualified clasname.
*
* Package notation is expected to be relative to a location
* on the PHP include_path. The dot-path classes are used as a way
* to represent both classname and filesystem location; there is
* an inherent assumption about filenaming. To get around these
* naming requirements you can include the class yourself
* and then just use the classname instead of dot-path.
*
* @param string $class dot-path to clas (e.g. path.to.my.ClassName).
* @return string unqualified classname
*/
public static function import($path) {
// extract classname
if (($pos = strrpos($path, '.')) === false) {
$class = $path;
} else {
$class = substr($path, $pos + 1);
}
// check if class exists
if (class_exists($class, false)) {
return $class;
}
// turn to filesystem path
$path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php';
// include class
$ret = include_once($path);
if ($ret === false) {
throw new PropelException("Unable to import class: " . $class . " from " . $path);
}
// return qualified name
return $class;
}
/**
* Closes any associated resource handles.
*
* This method frees any database connection handles that have been
* opened by the getConnection() method.
*
* @return void
*/
public static function close()
{
foreach(self::$connectionMap as $conn) {
$conn->close();
}
}
}

61
lib/symfony/vendor/propel/PropelException.php vendored Executable file
View File

@ -0,0 +1,61 @@
<?php
/*
* $Id: PropelException.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* The base class of all exceptions thrown by Propel.
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel
*/
class PropelException extends Exception {
/** The nested "cause" exception. */
protected $cause;
function __construct($p1, $p2 = null) {
$cause = null;
if ($p2 !== null) {
$msg = $p1;
$cause = $p2;
} else {
if ($p1 instanceof Exception) {
$msg = "";
$cause = $p1;
} else {
$msg = $p1;
}
}
parent::__construct($msg);
if ($cause !== null) {
$this->cause = $cause;
$this->message .= " [wrapped: " . $cause->getMessage() ."]";
}
}
function getCause() {
return $this->cause;
}
}

View File

@ -0,0 +1,184 @@
<?php
/*
* $Id: DBAdapter.php 536 2007-01-10 14:30:38Z 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>.
*/
include_once 'creole/Connection.php';
/**
* 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
* 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: 536 $
* @package propel.adapter
*/
abstract class DBAdapter {
/**
* Creole driver to Propel adapter map.
* @var array
*/
private static $adapters = array(
'mysql' => 'DBMySQL',
'mysqli' => 'DBMySQLi',
'mssql' => 'DBMSSQL',
'sybase' => 'DBSybase',
'oracle' => 'DBOracle',
'pgsql' => 'DBPostgres',
'sqlite' => 'DBSQLite',
'' => 'DBNone',
);
/**
* 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) {
require_once 'propel/adapter/'.$adapterClass.'.php';
$a = new $adapterClass();
return $a;
} else {
throw new PropelException("Unsupported Propel driver: " . $driver . ": Check your configuration file");
}
}
/**
* This method is used to ignore case.
*
* @param in 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 '\'';
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @return void
* @throws SQLException No Statement could be created or executed.
*/
public abstract function lockTable(Connection $con, $table);
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @return void
* @throws SQLException No Statement could be created or executed.
*/
public abstract function unlockTable(Connection $con, $table);
/**
* 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 . '"';
}
}

36
lib/symfony/vendor/propel/adapter/DBMSSQL.php vendored Executable file
View File

@ -0,0 +1,36 @@
<?php
/*
* $Id: DBMSSQL.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBSybase.php';
/**
* This is used to connect to a MSSQL database. For now, this class
* simply extends the adaptor for Sybase.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Gonzalo Diethelm <gonzalo.diethelm@sonda.com> (Torque)
* @version $Revision: 536 $
* @package propel.adapter
*/
class DBMSSQL extends DBSybase {
// no difference currently
}

133
lib/symfony/vendor/propel/adapter/DBMySQL.php vendored Executable file
View File

@ -0,0 +1,133 @@
<?php
/*
* $Id: DBMySQL.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* 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: 536 $
* @package propel.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 Creole connection to use.
* @param string $table The name of the table to lock.
* @throws SQLException No Statement could be created or
* executed.
*/
public function lockTable(Connection $con, $table)
{
$statement = $con->createStatement();
$sql = "LOCK TABLE " . $table . " WRITE";
$statement->executeUpdate($sql);
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @throws SQLException No Statement could be created or
* executed.
*/
public function unlockTable(Connection $con, $table)
{
$statement = $con->createStatement();
$statement->executeUpdate("UNLOCK TABLES");
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '`' . $text . '`';
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
* $Id: DBMySQLi.php 3750 2007-04-11 08:39:43Z fabien $
*
* 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>.
*/
require_once 'propel/adapter/DBMySQL.php';
/**
* This is used in order to connect to a MySQL database using the new mysqli API.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @version $Revision: 536 $
* @package propel.adapter
*/
class DBMySQLi extends DBMySQL {
}

131
lib/symfony/vendor/propel/adapter/DBNone.php vendored Executable file
View File

@ -0,0 +1,131 @@
<?php
/*
* $Id: DBNone.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* This DatabaseHandler 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: 536 $
* @package propel.adapter
*/
class DBNone extends DBAdapter {
/**
* @return null
*/
public function getConnection()
{
return null;
}
/**
* @see DBAdapter::init()
*/
public function init($url, $username, $password)
{
}
/**
* 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);
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @throws SQLException No Statement could be created or executed.
*/
public function lockTable(Connection $con, $table)
{
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @throws SQLException No Statement could be created or executed.
*/
public function unlockTable(Connection $con, $table)
{
}
}

123
lib/symfony/vendor/propel/adapter/DBOracle.php vendored Executable file
View File

@ -0,0 +1,123 @@
<?php
/*
* $Id: DBOracle.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* 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: 536 $
* @package propel.adapter
*/
class DBOracle 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 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)";
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @throws SQLException No Statement could be created or executed.
*/
public function lockTable(Connection $con, $table)
{
$statement = $con->createStatement();
$statement->executeQuery("SELECT next_id FROM " . $table ." FOR UPDATE");
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @throws SQLException - No Statement could be created or executed.
*/
public function unlockTable(Connection $con, $table)
{
// Tables in Oracle are unlocked when a commit is issued. The
// user may have issued a commit but do it here to be sure.
$con->commit();
}
}

View File

@ -0,0 +1,117 @@
<?php
/*
* $Id: DBPostgres.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* 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: 536 $
* @package propel.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)";
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @exception SQLException No Statement could be created or executed.
*/
public function lockTable(Connection $con, $table)
{
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @exception SQLException No Statement could be created or executed.
*/
public function unlockTable(Connection $con, $table)
{
}
}

124
lib/symfony/vendor/propel/adapter/DBSQLite.php vendored Executable file
View File

@ -0,0 +1,124 @@
<?php
/*
* $Id: DBSQLite.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* This is used in order to connect to a SQLite database.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.adapter
*/
class DBSQLite 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 "($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)";
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @throws SQLException No Statement could be created or
* executed.
*/
public function lockTable(Connection $con, $table)
{
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @throws SQLException No Statement could be created or
* executed.
*/
public function unlockTable(Connection $con, $table)
{
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
}

133
lib/symfony/vendor/propel/adapter/DBSybase.php vendored Executable file
View File

@ -0,0 +1,133 @@
<?php
/*
* $Id: DBSybase.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/adapter/DBAdapter.php';
/**
* This is used to connect to a Sybase database using Sybase's
* Creole driver.
*
* <B>NOTE:</B><I>Currently JConnect does not implement the required
* methods for ResultSetMetaData, and therefore the village API's may
* not function. For connection pooling, everything works.</I>
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Jeff Brekke <ekkerbj@netscape.net> (Torque)
* @version $Revision: 536 $
* @package propel.adapter
*/
class DBSybase 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 "($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)";
}
/**
* Locks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to lock.
* @throws SQLException No Statement could be created or executed.
*/
public function lockTable(Connection $con, $table)
{
$statement = $con->createStatement();
$sql = "SELECT next_id FROM " . $table . " FOR UPDATE";
$statement->executeQuery($sql);
}
/**
* Unlocks the specified table.
*
* @param Connection $con The Creole connection to use.
* @param string $table The name of the table to unlock.
* @throws SQLException No Statement could be created or executed.
*/
public function unlockTable(Connection $con, $table)
{
// Tables in Sybase are unlocked when a commit is issued. The
// user may have issued a commit but do it here to be sure.
$con->commit();
}
/**
* @see DBAdapter::quoteIdentifier()
*/
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
}

View File

@ -0,0 +1,103 @@
<?php
/*
* $Id: BasicLogger.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* This is a minimalistic interface that any logging class must implement for Propel.
*
* The API for this interface is based on the PEAR::Log interface. It provides a simple
* API that can be used by Propel independently of Log backend.
*
* PEAR::Log and perhaps the Log API was developed by Chuck Hagenbuch <chuck@horde.org>
* and Jon Parise <jon@php.net>.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.logger
*/
interface BasicLogger {
/**
* A convenience function for logging an alert event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function alert($message);
/**
* A convenience function for logging a critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function crit($message);
/**
* A convenience function for logging an error event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function err($message);
/**
* A convenience function for logging a warning event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function warning($message);
/**
* A convenience function for logging an critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function notice($message);
/**
* A convenience function for logging an critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function info($message);
/**
* A convenience function for logging a debug event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function debug($message);
/**
* Primary method to handle logging.
*
* @param mixed $message String or Exception object containing the message
* to log.
* @param int $severity The numeric severity. Defaults to null so that no
* assumptions are made about the logging backend.
*/
public function log($message, $severity = null);
}

View File

@ -0,0 +1,173 @@
<?php
/*
* $Id: MojaviLogAdapter.php 536 2007-01-10 14:30:38Z 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>.
*/
// include BasicLogger from include path
require_once('propel/logger/BasicLogger.php');
/**
* Mojavi logging adapter for propel
*
* @author Brandon Keepers <brandon@opensoul.org>
* @version $Revision: 536 $
* @package propel.logger
*/
class MojaviLogAdapter implements BasicLogger {
/**
* Instance of mojavi logger
*/
private $logger = null;
/**
* constructor for setting up Mojavi log adapter
*
* @param ErrorLog $logger instance of Mojavi error log obtained by
* calling LogManager::getLogger();
*/
public function __construct($logger = null)
{
$this->logger = $logger;
}
/**
* A convenience function for logging an alert event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function alert($message)
{
$this->log($message, 'alert');
}
/**
* A convenience function for logging a critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function crit($message)
{
$this->log($message, 'crit');
}
/**
* A convenience function for logging an error event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function err($message)
{
$this->log($message, 'err');
}
/**
* A convenience function for logging a warning event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function warning($message)
{
$this->log($message, 'warning');
}
/**
* A convenience function for logging an critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function notice($message)
{
$this->log($message, 'notice');
}
/**
* A convenience function for logging an critical event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function info($message)
{
$this->log($message, 'info');
}
/**
* A convenience function for logging a debug event.
*
* @param mixed $message String or Exception object containing the message
* to log.
*/
public function debug($message)
{
$this->log($message, 'debug');
}
/**
* Primary method to handle logging.
*
* @param mixed $message String or Exception object containing the message
* to log.
* @param int $severity The numeric severity. Defaults to null so that no
* assumptions are made about the logging backend.
*/
public function log($message, $severity = null)
{
if(is_null($this->logger))
$this->logger = LogManager::getLogger('propel');
switch($severity)
{
case 'crit':
$method = 'fatal';
break;
case 'err':
$method = 'error';
break;
case 'alert':
case 'warning':
$method = 'warning';
break;
case 'notice':
case 'info':
$method = 'info';
break;
case 'debug':
default:
$method = 'debug';
}
// get a backtrace to pass class, function, file, & line to Mojavi logger
$trace = debug_backtrace();
// call the appropriate Mojavi logger method
$this->logger->{$method} (
$message,
$trace[2]['class'],
$trace[2]['function'],
$trace[1]['file'],
$trace[1]['line']
);
}
}

344
lib/symfony/vendor/propel/map/ColumnMap.php vendored Executable file
View File

@ -0,0 +1,344 @@
<?php
/*
* $Id: ColumnMap.php 536 2007-01-10 14:30:38Z 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>.
*/
include_once 'propel/map/ValidatorMap.php';
/**
* ColumnMap is used to model a column of a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class ColumnMap {
/** @var int Creole type for this column. */
private $creoleType;
/** @var string Native PHP type of the column. */
private $type = null;
/** Size of the column. */
private $size = 0;
/** Is it a primary key? */
private $pk = false;
/** Is null value allowed ?*/
private $notNull = false;
/** Name of the table that this column is related to. */
private $relatedTableName = "";
/** Name of the column that this column is related to. */
private $relatedColumnName = "";
/** The TableMap for this column. */
private $table;
/** The name of the column. */
private $columnName;
/** The php name of the column. */
private $phpName;
/** validators for this column */
private $validators = array();
/**
* Constructor.
*
* @param string $name The name of the column.
* @param TableMap containingTable TableMap of the table this column is in.
*/
public function __construct($name, TableMap $containingTable)
{
$this->columnName = $name;
$this->table = $containingTable;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getColumnName()
{
return $this->columnName;
}
/**
* Set the php anme of this column.
*
* @param string $phpName A string representing the PHP name.
* @return void
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Get the table name + column name.
*
* @return string A String with the full column name.
*/
public function getFullyQualifiedName()
{
return $this->table->getName() . "." . $this->columnName;
}
/**
* Get the table map this column belongs to.
* @return TableMap
*/
public function getTable()
{
return $this->table;
}
/**
* Get the name of the table this column is in.
*
* @return string A String with the table name.
*/
public function getTableName()
{
return $this->table->getName();
}
/**
* Set the type of this column.
*
* @param string $type A string representing the PHP native type.
* @return void
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Set the Creole type of this column.
*
* @param int $type An int representing Creole type for this column.
* @return void
*/
public function setCreoleType($type)
{
$this->creoleType = $type;
}
/**
* Set the size of this column.
*
* @param int $size An int specifying the size.
* @return void
*/
public function setSize($size)
{
$this->size = $size;
}
/**
* Set if this column is a primary key or not.
*
* @param boolean $pk True if column is a primary key.
* @return void
*/
public function setPrimaryKey($pk)
{
$this->pk = $pk;
}
/**
* Set if this column may be null.
*
* @param boolean nn True if column may be null.
* @return void
*/
public function setNotNull($nn)
{
$this->notNull = $nn;
}
/**
* Gets the default value for this column.
* @return mixed String or NULL
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
/**
* Set the foreign key for this column.
*
* @param string tableName The name of the table that is foreign.
* @param string columnName The name of the column that is foreign.
* @return void
*/
public function setForeignKey($tableName, $columnName)
{
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
} else {
$this->relatedTableName = "";
$this->relatedColumnName = "";
}
}
public function addValidator($validator)
{
$this->validators[] = $validator;
}
public function hasValidators()
{
return count($this->validators) > 0;
}
public function getValidators()
{
return $this->validators;
}
/**
* Get the native PHP type of this column.
*
* @return string A string specifying the native PHP type.
*/
public function getType()
{
return $this->type;
}
/**
* Get the Creole type of this column.
*
* @return string A string specifying the native PHP type.
*/
public function getCreoleType()
{
return $this->creoleType;
}
/**
* Get the size of this column.
*
* @return int An int specifying the size.
*/
public function getSize()
{
return $this->size;
}
/**
* Is this column a primary key?
*
* @return boolean True if column is a primary key.
*/
public function isPrimaryKey()
{
return $this->pk;
}
/**
* Is null value allowed ?
*
* @return boolean True if column may be null.
*/
public function isNotNull()
{
return ($this->notNull || $this->isPrimaryKey());
}
/**
* Is this column a foreign key?
*
* @return boolean True if column is a foreign key.
*/
public function isForeignKey()
{
if ($this->relatedTableName) {
return true;
} else {
return false;
}
}
/**
* Get the table.column that this column is related to.
*
* @return string A String with the full name for the related column.
*/
public function getRelatedName()
{
return $this->relatedTableName . "." . $this->relatedColumnName;
}
/**
* Get the table name that this column is related to.
*
* @return string A String with the name for the related table.
*/
public function getRelatedTableName()
{
return $this->relatedTableName;
}
/**
* Get the column name that this column is related to.
*
* @return string A String with the name for the related column.
*/
public function getRelatedColumnName()
{
return $this->relatedColumnName;
}
}

127
lib/symfony/vendor/propel/map/DatabaseMap.php vendored Executable file
View File

@ -0,0 +1,127 @@
<?php
/*
* $Id: DatabaseMap.php 536 2007-01-10 14:30:38Z 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>.
*/
include_once 'propel/map/TableMap.php';
/**
* DatabaseMap is used to model a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@collab.net> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class DatabaseMap {
/** Name of the database. */
private $name;
/** Name of the tables in the database. */
private $tables;
/**
* Constructor.
*
* @param string $name Name of the database.
*/
function __construct($name)
{
$this->name = $name;
$this->tables = array();
}
/**
* Does this database contain this specific table?
*
* @param string $name The String representation of the table.
* @return boolean True if the database contains the table.
*/
public function containsTable($name)
{
if ( strpos($name, '.') > 0) {
$name = substr($name, 0, strpos($name, '.'));
}
return isset($this->tables[$name]);
}
/**
* Get the name of this database.
*
* @return string The name of the database.
*/
public function getName()
{
return $this->name;
}
/**
* Get a TableMap for the table by name.
*
* @param string $name Name of the table.
* @return TableMap A TableMap
* @throws PropelException if the table is undefined
*/
public function getTable($name)
{
if (!isset($this->tables[$name])) {
throw new PropelException("Cannot fetch TableMap for undefined table: " . $name);
}
return $this->tables[$name];
}
/**
* Get a TableMap[] of all of the tables in the database.
*
* @return array A TableMap[].
*/
public function getTables()
{
return $this->tables;
}
/**
* Add a new table to the database by name. It creates an empty
* TableMap that you need to populate.
*
* @param string $tableName The name of the table.
* @return TableMap The newly created TableMap.
*/
public function addTable($tableName)
{
$this->tables[$tableName] = new TableMap($tableName, $this);
return $this->tables[$tableName];
}
}

75
lib/symfony/vendor/propel/map/MapBuilder.php vendored Executable file
View File

@ -0,0 +1,75 @@
<?php
/*
* $Id: MapBuilder.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* MapBuilders are classes that construct a model of a database at runtime.
*
* MapBuilders support a single database, so this class essentially serves as
* a wrapper around the DatabaseMap class. This interface can be used for any
* class that needs to construct a runtime database model; by default in Propel
* the MapBuilder.tpl generates a class for your datamodel that implements this
* interface and re-creates your database using the DatabaseMap, TableMap,
* ColumnMap, and ValidatorMap classes.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Hans Lellelid <hans@xmpl.org> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
interface MapBuilder {
/**
* Build up the database mapping.
* @return void
* @throws Exception Couldn't build mapping.
*/
function doBuild();
/**
* Tells us if the database mapping is built so that we can avoid
* re-building it repeatedly.
*
* @return boolean Whether the DatabaseMap is built.
*/
function isBuilt();
/**
* Gets the database mapping this map builder built.
*
* @return DatabaseMap A DatabaseMap.
*/
function getDatabaseMap();
}

429
lib/symfony/vendor/propel/map/TableMap.php vendored Executable file
View File

@ -0,0 +1,429 @@
<?php
/*
* $Id: TableMap.php 536 2007-01-10 14:30:38Z 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>.
*/
include_once 'propel/map/ColumnMap.php';
include_once 'propel/map/ValidatorMap.php';
/**
* TableMap is used to model a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class TableMap {
/** The columns in the table. */
private $columns;
/** The database this table belongs to. */
private $dbMap;
/** The name of the table. */
private $tableName;
/** The PHP name of the table. */
private $phpName;
/** The prefix on the table name. */
private $prefix;
/** Whether to use an id generator for pkey. */
private $useIdGenerator;
/**
* Object to store information that is needed if the
* for generating primary keys.
*/
private $pkInfo;
/**
* Construct a new TableMap.
*
* @param string $tableName The name of the table.
* @param DatabaseMap $containingDB A DatabaseMap that this table belongs to.
*/
public function __construct($tableName, DatabaseMap $containingDB)
{
$this->tableName = $tableName;
$this->dbMap = $containingDB;
$this->columns = array();
}
/**
* Normalizes the column name, removing table prefix and uppercasing.
* @param string $name
* @return string Normalized column name.
*/
private function normalizeColName($name) {
if (false !== ($pos = strpos($name, '.'))) {
$name = substr($name, $pos + 1);
}
$name = strtoupper($name);
return $name;
}
/**
* Does this table contain the specified column?
*
* @param string $name name of the column
* @return boolean True if the table contains the column.
*/
public function containsColumn($name)
{
if (!is_string($name)) {
$name = $name->getColumnName();
}
return isset($this->columns[$this->normalizeColName($name)]);
}
/**
* Get the DatabaseMap containing this TableMap.
*
* @return DatabaseMap A DatabaseMap.
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* Get the name of the Table.
*
* @return string A String with the name of the table.
*/
public function getName()
{
return $this->tableName;
}
/**
* Get the PHP name of the Table.
*
* @return string A String with the name of the table.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Set the PHP name of the Table.
*
* @param string $phpName The PHP Name for this table
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get table prefix name.
*
* @return string A String with the prefix.
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* Set table prefix name.
*
* @param string $prefix The prefix for the table name (ie: SCARAB for
* SCARAB_PROJECT).
* @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Whether to use Id generator for primary key.
* @return boolean
*/
public function isUseIdGenerator() {
return $this->useIdGenerator;
}
/**
* Get the information used to generate a primary key
*
* @return An Object.
*/
public function getPrimaryKeyMethodInfo()
{
return $this->pkInfo;
}
/**
* Get a ColumnMap[] of the columns in this table.
*
* @return array A ColumnMap[].
*/
public function getColumns()
{
return $this->columns;
}
/**
* Get a ColumnMap for the named table.
*
* @param string $name A String with the name of the table.
* @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumn($name)
{
$name = $this->normalizeColName($name);
if (!isset($this->columns[$name])) {
throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name);
}
return $this->columns[$name];
}
/**
* Add a primary key column to this Table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param $size An int specifying the size.
* @return ColumnMap Newly added PrimaryKey column.
*/
public function addPrimaryKey($columnName, $phpName, $type, $creoleType, $isNotNull = false, $size = null)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, true, null, null);
}
/**
* Add a foreign key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly added ForeignKey column.
*/
public function addForeignKey($columnName, $phpName, $type, $creoleType, $fkTable, $fkColumn, $isNotNull = false, $size = 0)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, false, $fkTable, $fkColumn);
}
/**
* Add a foreign primary key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly created foreign pkey column.
*/
public function addForeignPrimaryKey($columnName, $phpName, $type, $creoleType, $fkTable, $fkColumn, $isNotNull = false, $size = 0)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, true, $fkTable, $fkColumn);
}
/**
* Add a pre-created column to this table. It will replace any
* existing column.
*
* @param ColumnMap $cmap A ColumnMap.
* @return ColumnMap The added column map.
*/
public function addConfiguredColumn($cmap)
{
$this->columns[ $cmap->getColumnName() ] = $cmap;
return $cmap;
}
/**
* Add a column to the table.
*
* @param string name A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param boolean $pk True if column is a primary key.
* @param string $fkTable A String with the foreign key table name.
* @param $fkColumn A String with the foreign key column name.
* @param string $defaultValue The default value for this column.
* @return ColumnMap The newly created column.
*/
public function addColumn($name, $phpName, $type, $creoleType, $isNotNull = false, $size = null, $pk = null, $fkTable = null, $fkColumn = null)
{
$col = new ColumnMap($name, $this);
if ($fkTable && $fkColumn) {
if (substr($fkColumn, '.') > 0 && substr($fkColumn, $fkTable) !== false) {
$fkColumn = substr($fkColumn, strlen($fkTable) + 1);
}
$col->setForeignKey($fkTable, $fkColumn);
}
$col->setType($type);
$col->setCreoleType($creoleType);
$col->setPrimaryKey($pk);
$col->setSize($size);
$col->setPhpName($phpName);
$col->setNotNull($isNotNull);
$this->columns[$name] = $col;
return $this->columns[$name];
}
/**
* Add a validator to a table's column
*
* @param string $columnName The name of the validator's column
* @param string $name The rule name of this validator
* @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
* @param string $value
* @param string $message The error message which is returned on invalid values
* @return void
*/
public function addValidator($columnName, $name, $classname, $value, $message)
{
if (false !== ($pos = strpos($columnName, '.'))) {
$columnName = substr($columnName, $pos + 1);
}
$col = $this->getColumn($columnName);
if ($col !== null) {
$validator = new ValidatorMap($col);
$validator->setName($name);
$validator->setClass($classname);
$validator->setValue($value);
$validator->setMessage($message);
$col->addValidator($validator);
}
}
/**
* Set whether or not to use Id generator for primary key.
* @param boolean $bit
*/
public function setUseIdGenerator($bit) {
$this->useIdGenerator = $bit;
}
/**
* Sets the pk information needed to generate a key
*
* @param $pkInfo information needed to generate a key
*/
public function setPrimaryKeyMethodInfo($pkInfo)
{
$this->pkInfo = $pkInfo;
}
//---Utility methods for doing intelligent lookup of table names
/**
* Tell me if i have PREFIX in my string.
*
* @param data A String.
* @return boolean True if prefix is contained in data.
*/
private function hasPrefix($data)
{
return (substr($data, $this->getPrefix()) !== false);
}
/**
* Removes the PREFIX.
*
* @param string $data A String.
* @return string A String with data, but with prefix removed.
*/
private function removePrefix($data)
{
return substr($data, strlen($this->getPrefix()));
}
/**
* Removes the PREFIX, removes the underscores and makes
* first letter caps.
*
* SCARAB_FOO_BAR becomes FooBar.
*
* @param data A String.
* @return string A String with data processed.
*/
public final function removeUnderScores($data)
{
$tmp = null;
$out = "";
if ($this->hasPrefix($data)) {
$tmp = $this->removePrefix($data);
} else {
$tmp = $data;
}
$tok = strtok($tmp, "_");
while ($tok) {
$out .= ucfirst($tok);
$tok = strtok("_");
}
return $out;
}
/**
* Makes the first letter caps and the rest lowercase.
*
* @param string $data A String.
* @return string A String with data processed.
*/
private function firstLetterCaps($data)
{
return(ucfirst(strtolower($data)));
}
}

109
lib/symfony/vendor/propel/map/ValidatorMap.php vendored Executable file
View File

@ -0,0 +1,109 @@
<?php
/*
* $Id: ValidatorMap.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* ValidatorMap is used to model a column validator.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.map
*/
class ValidatorMap
{
/** rule name of this validator */
private $name;
/** the dot-path to class to use for validator */
private $classname;
/** value to check against */
private $value;
/** execption message thrown on invalid input */
private $message;
/** related column */
private $column;
public function __construct($containingColumn)
{
$this->column = $containingColumn;
}
public function getColumn()
{
return $this->column;
}
public function getColumnName()
{
return $this->column->getColumnName();
}
public function setName($name)
{
$this->name = $name;
}
public function setClass($classname)
{
$this->classname = $classname;
}
public function setValue($value)
{
$this->value = $value;
}
public function setMessage($message)
{
$this->message = $message;
}
public function getName()
{
return $this->name;
}
public function getClass()
{
return $this->classname;
}
public function getValue()
{
return $this->value;
}
public function getMessage()
{
return $this->message;
}
}

187
lib/symfony/vendor/propel/om/BaseObject.php vendored Executable file
View File

@ -0,0 +1,187 @@
<?php
/*
* $Id: BaseObject.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/om/Persistent.php';
/**
* This class contains attributes and methods that are used by all
* business objects within the system.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Frank Y. Kim <frank.kim@clearink.com> (Torque)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @version $Revision: 536 $
* @package propel.om
*/
abstract class BaseObject {
/**
* attribute to determine if this object has previously been saved.
* @var boolean
*/
private $_new = true;
/**
* attribute to determine whether this object has been deleted.
* @var boolean
*/
private $_deleted = false;
/**
* The columns that have been modified in current object.
* Tracking modified columns allows us to only update modified columns.
* @var array
*/
protected $modifiedColumns = array();
/**
* Returns whether the object has been modified.
*
* @return boolean True if the object has been modified.
*/
public function isModified()
{
return !empty($this->modifiedColumns);
}
/**
* Has specified column been modified?
*
* @param string $col
* @return boolean True if $col has been modified.
*/
public function isColumnModified($col)
{
return in_array($col, $this->modifiedColumns);
}
/**
* Returns whether the object has ever been saved. This will
* be false, if the object was retrieved from storage or was created
* and then saved.
*
* @return true, if the object has never been persisted.
*/
public function isNew()
{
return $this->_new;
}
/**
* Setter for the isNew attribute. This method will be called
* by Propel-generated children and Peers.
*
* @param boolean $b the state of the object.
*/
public function setNew($b)
{
$this->_new = (boolean) $b;
}
/**
* Whether this object has been deleted.
* @return boolean The deleted state of this object.
*/
public function isDeleted()
{
return $this->_deleted;
}
/**
* Specify whether this object has been deleted.
* @param boolean $b The deleted state of this object.
* @return void
*/
public function setDeleted($b)
{
$this->_deleted = (boolean) $b;
}
/**
* Sets the modified state for the object to be false.
* @param string $col If supplied, only the specified column is reset.
* @return void
*/
public function resetModified($col = null)
{
if ($col !== null)
{
while (($offset = array_search($col, $this->modifiedColumns)) !== false)
array_splice($this->modifiedColumns, $offset, 1);
}
else
{
$this->modifiedColumns = array();
}
}
/**
* Compares this with another <code>BaseObject</code> instance. If
* <code>obj</code> is an instance of <code>BaseObject</code>, delegates to
* <code>equals(BaseObject)</code>. Otherwise, returns <code>false</code>.
*
* @param obj The object to compare to.
* @return Whether equal to the object specified.
*/
public function equals($obj)
{
if (is_object($obj)) {
if ($this === $obj) {
return true;
} elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) {
return false;
} else {
return ($this->getPrimaryKey() === $obj->getPrimaryKey());
}
} else {
return false;
}
}
/**
* If the primary key is not <code>null</code>, return the hashcode of the
* primary key. Otherwise calls <code>Object.hashCode()</code>.
*
* @return int Hashcode
*/
public function hashCode()
{
$ok = $this->getPrimaryKey();
if ($ok === null) {
return crc32(serialize($this));
}
return crc32(serialize($ok)); // serialize because it could be an array ("ComboKey")
}
/**
* Logs a message using Propel::log().
*
* @param string $msg
* @param int $priority One of the Propel::LOG_* logging levels
* @return boolean
*/
protected function log($msg, $priority = Propel::LOG_INFO)
{
return Propel::log(get_class($this) . ': ' . $msg, $priority);
}
}

118
lib/symfony/vendor/propel/om/Persistent.php vendored Executable file
View File

@ -0,0 +1,118 @@
<?php
/*
* $Id: Persistent.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* This interface defines methods related to saving an object
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Fedor K. <fedor@apache.org> (Torque)
* @version $Revision: 536 $
* @package propel.om
*/
interface Persistent {
/**
* getter for the object primaryKey.
*
* @return ObjectKey the object primaryKey as an Object
*/
public function getPrimaryKey();
/**
* Sets the PrimaryKey for the object.
*
* @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()).
* @return void
* @throws Exception, This method might throw an exceptions
*/
public function setPrimaryKey($primaryKey);
/**
* Returns whether the object has been modified, since it was
* last retrieved from storage.
*
* @return boolean True if the object has been modified.
*/
public function isModified();
/**
* Has specified column been modified?
*
* @param string $col
* @return boolean True if $col has been modified.
*/
public function isColumnModified($col);
/**
* Returns whether the object has ever been saved. This will
* be false, if the object was retrieved from storage or was created
* and then saved.
*
* @return boolean True, if the object has never been persisted.
*/
public function isNew();
/**
* Setter for the isNew attribute. This method will be called
* by Propel-generated children and Peers.
*
* @param boolean $b the state of the object.
*/
public function setNew($b);
/**
* Resets (to false) the "modified" state for this object.
*
* @return void
*/
public function resetModified();
/**
* Whether this object has been deleted.
* @return boolean The deleted state of this object.
*/
public function isDeleted();
/**
* Specify whether this object has been deleted.
* @param boolean $b The deleted state of this object.
* @return void
*/
public function setDeleted($b);
/**
* Deletes the object.
* @param Connection $con
* @return void
* @throws Exception
*/
public function delete($con = null);
/**
* Saves the object.
* @param Connection $con
* @return void
* @throws Exception
*/
public function save($con = null);
}

View File

@ -0,0 +1,90 @@
<?php
/*
* $Id: PreOrderNodeIterator.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* Pre-order node iterator for Node objects.
*
* @author Dave Lawson <dlawson@masterytech.com>
* @version $Revision: 536 $
* @package propel.om
*/
class PreOrderNodeIterator implements Iterator
{
private $topNode = null;
private $curNode = null;
private $querydb = false;
private $con = null;
public function __construct($node, $opts) {
$this->topNode = $node;
$this->curNode = $node;
if (isset($opts['con']))
$this->con = $opts['con'];
if (isset($opts['querydb']))
$this->querydb = $opts['querydb'];
}
public function rewind() {
$this->curNode = $this->topNode;
}
public function valid() {
return ($this->curNode !== null);
}
public function current() {
return $this->curNode;
}
public function key() {
return $this->curNode->getNodePath();
}
public function next() {
if ($this->valid())
{
$nextNode = $this->curNode->getFirstChildNode($this->querydb, $this->con);
while ($nextNode === null)
{
if ($this->curNode === null || $this->curNode->equals($this->topNode))
break;
$nextNode = $this->curNode->getSiblingNode(false, $this->querydb, $this->con);
if ($nextNode === null)
$this->curNode = $this->curNode->getParentNode($this->querydb, $this->con);
}
$this->curNode = $nextNode;
}
return $this->curNode;
}
}

945
lib/symfony/vendor/propel/util/BasePeer.php vendored Executable file
View File

@ -0,0 +1,945 @@
<?php
/*
* $Id: BasePeer.php 536 2007-01-10 14:30:38Z 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>.
*/
include_once 'propel/adapter/DBAdapter.php';
include_once 'propel/map/ColumnMap.php';
include_once 'propel/map/DatabaseMap.php';
include_once 'propel/map/MapBuilder.php';
include_once 'propel/map/TableMap.php';
include_once 'propel/map/ValidatorMap.php';
include_once 'propel/validator/ValidationFailed.php';
/**
* This is a utility class for all generated Peer classes in the system.
*
* Peer classes are responsible for isolating all of the database access
* for a specific business object. They execute all of the SQL
* against the database. Over time this class has grown to include
* utility methods which ease execution of cross-database queries and
* the implementation of concrete Peers.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Kaspars Jaudzems <kaspars.jaudzems@inbox.lv> (Propel)
* @author Frank Y. Kim <frank.kim@clearink.com> (Torque)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Brett McLaughlin <bmclaugh@algx.net> (Torque)
* @author Stephen Haberman <stephenh@chase3000.com> (Torque)
* @version $Revision: 536 $
* @package propel.util
*/
class BasePeer
{
/** Array (hash) that contains the cached mapBuilders. */
private static $mapBuilders = array();
/** Array (hash) that contains cached validators */
private static $validatorMap = array();
/**
* phpname type
* e.g. 'AuthorId'
*/
const TYPE_PHPNAME = 'phpName';
/**
* column (peer) name type
* e.g. 'book.AUTHOR_ID'
*/
const TYPE_COLNAME = 'colName';
/**
* column fieldname type
* e.g. 'author_id'
*/
const TYPE_FIELDNAME = 'fieldName';
/**
* num type
* simply the numerical array index, e.g. 4
*/
const TYPE_NUM = 'num';
static public function getFieldnames ($classname, $type = self::TYPE_PHPNAME) {
// TODO we should take care of including the peer class here
$peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true?
$callable = array($peerclass, 'getFieldnames');
$args = array($type);
return call_user_func_array($callable, $args);
}
static public function translateFieldname($classname, $fieldname, $fromType, $toType) {
// TODO we should take care of including the peer class here
$peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true?
$callable = array($peerclass, 'translateFieldname');
$args = array($fieldname, $fromType, $toType);
return call_user_func_array($callable, $args);
}
/**
* Method to perform deletes based on values and keys in a
* Criteria.
*
* @param Criteria $criteria The criteria to use.
* @param Connection $con A Connection.
* @return int The number of rows affected by last statement execution. For most
* uses there is only one delete statement executed, so this number
* will correspond to the number of rows affected by the call to this
* method. Note that the return value does require that this information
* is returned (supported) by the Creole db driver.
* @throws PropelException
*/
public static function doDelete(Criteria $criteria, Connection $con)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
// Set up a list of required tables (one DELETE statement will
// be executed per table)
$tables_keys = array();
foreach($criteria as $c) {
foreach($c->getAllTables() as $tableName) {
$tableName2 = $criteria->getTableForAlias($tableName);
if ($tableName2 !== null) {
$tables_keys[$tableName2 . ' ' . $tableName] = true;
} else {
$tables_keys[$tableName] = true;
}
}
} // foreach criteria->keys()
$affectedRows = 0; // initialize this in case the next loop has no iterations.
$tables = array_keys($tables_keys);
foreach($tables as $tableName) {
$whereClause = array();
$selectParams = array();
foreach($dbMap->getTable($tableName)->getColumns() as $colMap) {
$key = $tableName . '.' . $colMap->getColumnName();
if ($criteria->containsKey($key)) {
$sb = "";
$criteria->getCriterion($key)->appendPsTo($sb, $selectParams);
$whereClause[] = $sb;
}
}
if (empty($whereClause)) {
throw new PropelException("Cowardly refusing to delete from table $tableName with empty WHERE clause.");
}
// Execute the statement.
try {
$sqlSnippet = implode(" AND ", $whereClause);
if ($criteria->isSingleRecord()) {
$sql = "SELECT COUNT(*) FROM " . $tableName . " WHERE " . $sqlSnippet;
$stmt = $con->prepareStatement($sql);
self::populateStmtValues($stmt, $selectParams, $dbMap);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
$rs->next();
if ($rs->getInt(1) > 1) {
$rs->close();
throw new PropelException("Expecting to delete 1 record, but criteria match multiple.");
}
$rs->close();
}
$sql = "DELETE FROM " . $tableName . " WHERE " . $sqlSnippet;
Propel::log($sql, Propel::LOG_DEBUG);
$stmt = $con->prepareStatement($sql);
self::populateStmtValues($stmt, $selectParams, $dbMap);
$affectedRows = $stmt->executeUpdate();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException("Unable to execute DELETE statement.",$e);
}
} // for each table
return $affectedRows;
}
/**
* Method to deletes all contents of specified table.
*
* This method is invoked from generated Peer classes like this:
* <code>
* public static function doDeleteAll($con = null)
* {
* if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME);
* BasePeer::doDeleteAll(self::TABLE_NAME, $con);
* }
* </code>
*
* @param string $tableName The name of the table to empty.
* @param Connection $con A Connection.
* @return int The number of rows affected by the statement. Note
* that the return value does require that this information
* is returned (supported) by the Creole db driver.
* @throws PropelException - wrapping SQLException caught from statement execution.
*/
public static function doDeleteAll($tableName, Connection $con)
{
try {
$sql = "DELETE FROM " . $tableName;
Propel::log($sql, Propel::LOG_DEBUG);
$stmt = $con->prepareStatement($sql);
return $stmt->executeUpdate();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException("Unable to perform DELETE ALL operation.", $e);
}
}
/**
* Method to perform inserts based on values and keys in a
* Criteria.
* <p>
* If the primary key is auto incremented the data in Criteria
* will be inserted and the auto increment value will be returned.
* <p>
* If the primary key is included in Criteria then that value will
* be used to insert the row.
* <p>
* If no primary key is included in Criteria then we will try to
* figure out the primary key from the database map and insert the
* row with the next available id using util.db.IDBroker.
* <p>
* If no primary key is defined for the table the values will be
* inserted as specified in Criteria and null will be returned.
*
* @param Criteria $criteria Object containing values to insert.
* @param Connection $con A Connection.
* @return mixed The primary key for the new row if (and only if!) the primary key
* is auto-generated. Otherwise will return <code>null</code>.
* @throws PropelException
*/
public static function doInsert(Criteria $criteria, Connection $con) {
// the primary key
$id = null;
// Get the table name and method for determining the primary
// key value.
$keys = $criteria->keys();
if (!empty($keys)) {
$tableName = $criteria->getTableName( $keys[0] );
} else {
throw new PropelException("Database insert attempted without anything specified to insert");
}
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$tableMap = $dbMap->getTable($tableName);
$keyInfo = $tableMap->getPrimaryKeyMethodInfo();
$useIdGen = $tableMap->isUseIdGenerator();
$keyGen = $con->getIdGenerator();
$pk = self::getPrimaryKey($criteria);
// only get a new key value if you need to
// the reason is that a primary key might be defined
// but you are still going to set its value. for example:
// a join table where both keys are primary and you are
// setting both columns with your own values
// pk will be null if there is no primary key defined for the table
// we're inserting into.
if ($pk !== null && $useIdGen && !$criteria->containsKey($pk->getFullyQualifiedName())) {
// If the keyMethod is SEQUENCE get the id before the insert.
if ($keyGen->isBeforeInsert()) {
try {
$id = $keyGen->getId($keyInfo);
} catch (Exception $e) {
throw new PropelException("Unable to get sequence id.", $e);
}
$criteria->add($pk->getFullyQualifiedName(), $id);
}
}
try {
$qualifiedCols = $criteria->keys(); // we need table.column cols when populating values
$columns = array(); // but just 'column' cols for the SQL
foreach($qualifiedCols as $qualifiedCol) {
$columns[] = substr($qualifiedCol, strpos($qualifiedCol, '.') + 1);
}
$sql = "INSERT INTO " . $tableName
. " (" . implode(",", $columns) . ")"
. " VALUES (" . substr(str_repeat("?,", count($columns)), 0, -1) . ")";
Propel::log($sql, Propel::LOG_DEBUG);
$stmt = $con->prepareStatement($sql);
self::populateStmtValues($stmt, self::buildParams($qualifiedCols, $criteria), $dbMap);
$stmt->executeUpdate();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException("Unable to execute INSERT statement.", $e);
}
// If the primary key column is auto-incremented, get the id
// now.
if ($pk !== null && $useIdGen && $keyGen->isAfterInsert()) {
try {
$id = $keyGen->getId($keyInfo);
} catch (Exception $e) {
throw new PropelException("Unable to get autoincrement id.", $e);
}
}
return $id;
}
/**
* Method used to update rows in the DB. Rows are selected based
* on selectCriteria and updated using values in updateValues.
* <p>
* Use this method for performing an update of the kind:
* <p>
* WHERE some_column = some value AND could_have_another_column =
* another value AND so on.
*
* @param $selectCriteria A Criteria object containing values used in where
* clause.
* @param $updateValues A Criteria object containing values used in set
* clause.
* @param $con The Connection to use.
* @return int The number of rows affected by last update statement. For most
* uses there is only one update statement executed, so this number
* will correspond to the number of rows affected by the call to this
* method. Note that the return value does require that this information
* is returned (supported) by the Creole db driver.
* @throws PropelException
*/
public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues, Connection $con) {
$db = Propel::getDB($selectCriteria->getDbName());
$dbMap = Propel::getDatabaseMap($selectCriteria->getDbName());
// Get list of required tables, containing all columns
$tablesColumns = $selectCriteria->getTablesColumns();
// we also need the columns for the update SQL
$updateTablesColumns = $updateValues->getTablesColumns();
$affectedRows = 0; // initialize this in case the next loop has no iterations.
foreach($tablesColumns as $tableName => $columns) {
$whereClause = array();
$selectParams = array();
foreach($columns as $colName) {
$sb = "";
$selectCriteria->getCriterion($colName)->appendPsTo($sb, $selectParams);
$whereClause[] = $sb;
}
$rs = null;
$stmt = null;
try {
$sqlSnippet = implode(" AND ", $whereClause);
if ($selectCriteria->isSingleRecord()) {
// Get affected records.
$sql = "SELECT COUNT(*) FROM " . $tableName . " WHERE " . $sqlSnippet;
$stmt = $con->prepareStatement($sql);
self::populateStmtValues($stmt, $selectParams, $dbMap);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
$rs->next();
if ($rs->getInt(1) > 1) {
$rs->close();
throw new PropelException("Expected to update 1 record, multiple matched.");
}
$rs->close();
}
$sql = "UPDATE " . $tableName . " SET ";
foreach($updateTablesColumns[$tableName] as $col) {
$sql .= substr($col, strpos($col, '.') + 1) . " = ?,";
}
$sql = substr($sql, 0, -1) . " WHERE " . $sqlSnippet;
Propel::log($sql, Propel::LOG_DEBUG);
$stmt = $con->prepareStatement($sql);
// Replace '?' with the actual values
self::populateStmtValues($stmt, array_merge(self::buildParams($updateTablesColumns[$tableName], $updateValues), $selectParams), $dbMap);
$affectedRows = $stmt->executeUpdate();
$stmt->close();
} catch (Exception $e) {
if ($rs) $rs->close();
if ($stmt) $stmt->close();
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException("Unable to execute UPDATE statement.", $e);
}
} // foreach table in the criteria
return $affectedRows;
}
/**
* Executes query build by createSelectSql() and returns ResultSet.
*
* @param Criteria $criteria A Criteria.
* @param Connection $con A connection to use.
* @return ResultSet The resultset.
* @throws PropelException
* @see createSelectSql()
*/
public static function doSelect(Criteria $criteria, $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
if ($con === null)
$con = Propel::getConnection($criteria->getDbName());
$stmt = null;
try {
// Transaction support exists for (only?) Postgres, which must
// have SELECT statements that include bytea columns wrapped w/
// transactions.
if ($criteria->isUseTransaction()) $con->begin();
$params = array();
$sql = self::createSelectSql($criteria, $params);
$stmt = $con->prepareStatement($sql);
$stmt->setLimit($criteria->getLimit());
$stmt->setOffset($criteria->getOffset());
self::populateStmtValues($stmt, $params, $dbMap);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
if ($criteria->isUseTransaction()) $con->commit();
} catch (Exception $e) {
if ($stmt) $stmt->close();
if ($criteria->isUseTransaction()) $con->rollback();
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException($e);
}
return $rs;
}
/**
* Applies any validators that were defined in the schema to the specified columns.
*
* @param string $dbName The name of the database
* @param string $tableName The name of the table
* @param array $columns Array of column names as key and column values as value.
*/
public static function doValidate($dbName, $tableName, $columns)
{
$dbMap = Propel::getDatabaseMap($dbName);
$tableMap = $dbMap->getTable($tableName);
$failureMap = array(); // map of ValidationFailed objects
foreach($columns as $colName => $colValue) {
if ($tableMap->containsColumn($colName)) {
$col = $tableMap->getColumn($colName);
foreach($col->getValidators() as $validatorMap) {
$validator = BasePeer::getValidator($validatorMap->getClass());
if($validator && ($col->isNotNull() || $colValue !== null) && $validator->isValid($validatorMap, $colValue) === false) {
if (!isset($failureMap[$colName])) { // for now we do one ValidationFailed per column, not per rule
$failureMap[$colName] = new ValidationFailed($colName, $validatorMap->getMessage(), $validator);
}
}
}
}
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Helper method which returns the primary key contained
* in the given Criteria object.
*
* @param Criteria $criteria A Criteria.
* @return ColumnMap If the Criteria object contains a primary
* key, or null if it doesn't.
* @throws PropelException
*/
private static function getPrimaryKey(Criteria $criteria)
{
// Assume all the keys are for the same table.
$keys = $criteria->keys();
$key = $keys[0];
$table = $criteria->getTableName($key);
$pk = null;
if (!empty($table)) {
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
if ($dbMap === null) {
throw new PropelException("\$dbMap is null");
}
if ($dbMap->getTable($table) === null) {
throw new PropelException("\$dbMap->getTable() is null");
}
$columns = $dbMap->getTable($table)->getColumns();
foreach(array_keys($columns) as $key) {
if ($columns[$key]->isPrimaryKey()) {
$pk = $columns[$key];
break;
}
}
}
return $pk;
}
/**
* Method to create an SQL query based on values in a Criteria.
*
* This method creates only prepared statement SQL (using ? where values
* will go). The second parameter ($params) stores the values that need
* to be set before the statement is executed. The reason we do it this way
* is to let the Creole layer handle all escaping & value formatting.
*
* @param Criteria $criteria Criteria for the SELECT query.
* @param array &$params Parameters that are to be replaced in prepared statement.
* @return string
* @throws PropelException Trouble creating the query string.
*/
public static function createSelectSql(Criteria $criteria, &$params) {
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
// redundant definition $selectModifiers = array();
$selectClause = array();
$fromClause = array();
$joinClause = array();
$joinTables = array();
$whereClause = array();
$orderByClause = array();
// redundant definition $groupByClause = array();
$orderBy = $criteria->getOrderByColumns();
$groupBy = $criteria->getGroupByColumns();
$ignoreCase = $criteria->isIgnoreCase();
$select = $criteria->getSelectColumns();
$aliases = $criteria->getAsColumns();
// simple copy
$selectModifiers = $criteria->getSelectModifiers();
// get selected columns
foreach($select as $columnName) {
// expect every column to be of "table.column" formation
// it could be a function: e.g. MAX(books.price)
$tableName = null;
$selectClause[] = $columnName; // the full column name: e.g. MAX(books.price)
$parenPos = strpos($columnName, '(');
$dotPos = strpos($columnName, '.');
// [HL] I think we really only want to worry about adding stuff to
// the fromClause if this function has a TABLE.COLUMN in it at all.
// e.g. COUNT(*) should not need this treatment -- or there needs to
// be special treatment for '*'
if ($dotPos !== false) {
if ($parenPos === false) { // table.column
$tableName = substr($columnName, 0, $dotPos);
} else { // FUNC(table.column)
$tableName = substr($columnName, $parenPos + 1, $dotPos - ($parenPos + 1));
// functions may contain qualifiers so only take the last
// word as the table name.
// COUNT(DISTINCT books.price)
$lastSpace = strpos($tableName, ' ');
if ($lastSpace !== false) { // COUNT(DISTINCT books.price)
$tableName = substr($tableName, $lastSpace + 1);
}
}
$tableName2 = $criteria->getTableForAlias($tableName);
if ($tableName2 !== null) {
$fromClause[] = $tableName2 . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
}
} // if $dotPost !== null
}
// set the aliases
foreach($aliases as $alias => $col) {
$selectClause[] = $col . " AS " . $alias;
}
// add the criteria to WHERE clause
// this will also add the table names to the FROM clause if they are not already
// invluded via a LEFT JOIN
foreach($criteria->keys() as $key) {
$criterion = $criteria->getCriterion($key);
$someCriteria = $criterion->getAttachedCriterion();
$someCriteriaLength = count($someCriteria);
$table = null;
for ($i=0; $i < $someCriteriaLength; $i++) {
$tableName = $someCriteria[$i]->getTable();
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
$table = $tableName;
}
$ignoreCase =
(($criteria->isIgnoreCase()
|| $someCriteria[$i]->isIgnoreCase())
&& ($dbMap->getTable($table)->getColumn($someCriteria[$i]->getColumn())->getType() == "string" )
);
$someCriteria[$i]->setIgnoreCase($ignoreCase);
}
$criterion->setDB($db);
$sb = "";
$criterion->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
// handle RIGHT (straight) joins
// Loop through the joins,
// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.
// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause
// New Code.
foreach ((array) $criteria->getJoins() as $join) { // we'll only loop if there's actually something here
// The join might have been established using an alias name
$leftTable = $join->getLeftTableName();
$leftTableAlias = '';
if ($realTable = $criteria->getTableForAlias($leftTable)) {
$leftTableAlias = " $leftTable";
$leftTable = $realTable;
}
$rightTable = $join->getRightTableName();
$rightTableAlias = '';
if ($realTable = $criteria->getTableForAlias($rightTable)) {
$rightTableAlias = " $rightTable";
$rightTable = $realTable;
}
// determine if casing is relevant.
if ($ignoreCase = $criteria->isIgnoreCase()) {
$leftColType = $dbMap->getTable($leftTable)->getColumn($join->getLeftColumnName())->getType();
$rightColType = $dbMap->getTable($rightTable)->getColumn($join->getRightColumnName())->getType();
$ignoreCase = ($leftColType == 'string' || $rightColType == 'string');
}
// build the condition
if ($ignoreCase) {
$condition = $db->ignoreCase($join->getLeftColumn()) . '=' . $db->ignoreCase($join->getRightColumn());
} else {
$condition = $join->getLeftColumn() . '=' . $join->getRightColumn();
}
// add 'em to the queues..
if ($joinType = $join->getJoinType()) {
if (!$fromClause) {
$fromClause[] = $leftTable . $leftTableAlias;
}
$joinTables[] = $rightTable . $rightTableAlias;
$joinClause[] = $join->getJoinType() . ' ' . $rightTable . $rightTableAlias . " ON ($condition)";
} else {
$fromClause[] = $leftTable . $leftTableAlias;
$fromClause[] = $rightTable . $rightTableAlias;
$whereClause[] = $condition;
}
}
// Unique from clause elements
$fromClause = array_unique($fromClause);
// tables should not exist in both the from and join clauses
if ($joinTables && $fromClause) {
foreach ($fromClause as $fi => $ftable) {
if (in_array($ftable, $joinTables)) {
unset($fromClause[$fi]);
}
}
}
/*
// Old Code.
$joins =& $criteria->getJoins();
if (!empty($joins)) {
for ($i=0, $joinSize=count($joins); $i < $joinSize; $i++) {
$join =& $joins[$i];
$join1 = $join->getLeftColumn();
$join2 = $join->getRightColumn();
$tableName = substr($join1, 0, strpos($join1, '.'));
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
}
$dot = strpos($join2, '.');
$tableName = substr($join2, 0, $dot);
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
$table = $tableName;
}
$ignoreCase = ($criteria->isIgnoreCase() && ($dbMap->getTable($table)->getColumn(substr($join2, $dot + 1))->getType() == "string"));
if ($ignoreCase) {
$whereClause[] = $db->ignoreCase($join1) . '=' . $db->ignoreCase($join2);
} else {
$whereClause[] = $join1 . '=' . $join2;
}
if ($join->getJoinType()) {
$leftTable = $fromClause[count($fromClause) - 2];
$rightTable = $fromClause[count($fromClause) - 1];
$onClause = $whereClause[count($whereClause) - 1];
unset($whereClause[count($whereClause) - 1]);
$fromClause [] = $leftTable . ' ' . $join->getJoinType() . ' ' . $rightTable . ' ON ' . $onClause;
// remove all references to joinTables made by selectColumns, criteriaColumns
for ($i = 0, $fromClauseSize=count($fromClause); $i < $fromClauseSize; $i++) {
if ($fromClause[$i] == $leftTable || $fromClause[$i] == $rightTable) {
unset($fromClause[$i]);
}
}
} // If join type
} // Join for loop
} // If Joins
*/
// Add the GROUP BY columns
$groupByClause = $groupBy;
$having = $criteria->getHaving();
$havingString = null;
if ($having !== null) {
$sb = "";
$having->appendPsTo($sb, $params);
$havingString = $sb;
}
if (!empty($orderBy)) {
foreach($orderBy as $orderByColumn) {
// Add function expression as-is.
if (strpos($orderByColumn, '(') !== false) {
$orderByClause[] = $orderByColumn;
continue;
}
// Split orderByColumn (i.e. "table.column DESC")
$dotPos = strpos($orderByColumn, '.');
if ($dotPos !== false) {
$tableName = substr($orderByColumn, 0, $dotPos);
$columnName = substr($orderByColumn, $dotPos+1);
}
else {
$tableName = '';
$columnName = $orderByColumn;
}
$spacePos = strpos($columnName, ' ');
if ($spacePos !== false) {
$direction = substr($columnName, $spacePos);
$columnName = substr($columnName, 0, $spacePos);
}
else {
$direction = '';
}
$tableAlias = $tableName;
if ($aliasTableName = $criteria->getTableForAlias($tableName)) {
$tableName = $aliasTableName;
}
$columnAlias = $columnName;
if ($asColumnName = $criteria->getColumnForAs($columnName)) {
$columnName = $asColumnName;
}
$column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null;
if ($column && $column->getType() == 'string') {
$orderByClause[] = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias") . $direction;
$selectClause[] = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias");
}
else {
$orderByClause[] = $orderByColumn;
}
}
}
// Build the SQL from the arrays we compiled
$sql = "SELECT "
.($selectModifiers ? implode(" ", $selectModifiers) . " " : "")
.implode(", ", $selectClause)
." FROM ". ( (!empty($joinClause) && count($fromClause) > 1 && (substr(get_class($db), 0, 7) == 'DBMySQL')) ? "(" . implode(", ", $fromClause) . ")" : implode(", ", $fromClause) )
.($joinClause ? ' ' . implode(' ', $joinClause) : '')
.($whereClause ? " WHERE ".implode(" AND ", $whereClause) : "")
.($groupByClause ? " GROUP BY ".implode(",", $groupByClause) : "")
.($havingString ? " HAVING ".$havingString : "")
.($orderByClause ? " ORDER BY ".implode(",", $orderByClause) : "");
Propel::log($sql . ' [LIMIT: ' . $criteria->getLimit() . ', OFFSET: ' . $criteria->getOffset() . ']', Propel::LOG_DEBUG);
return $sql;
}
/**
* Builds a params array, like the kind populated by Criterion::appendPsTo().
* This is useful for building an array even when it is not using the appendPsTo() method.
* @param array $columns
* @param Criteria $values
* @return array params array('column' => ..., 'table' => ..., 'value' => ...)
*/
private static function buildParams($columns, Criteria $values) {
$params = array();
foreach($columns as $key) {
if ($values->containsKey($key)) {
$crit = $values->getCriterion($key);
$params[] = array('column' => $crit->getColumn(), 'table' => $crit->getTable(), 'value' => $crit->getValue());
}
}
return $params;
}
/**
* Populates values in a prepared statement.
*
* @param PreparedStatement $stmt
* @param array $params array('column' => ..., 'table' => ..., 'value' => ...)
* @param DatabaseMap $dbMap
* @return int The number of params replaced.
*/
private static function populateStmtValues($stmt, $params, DatabaseMap $dbMap)
{
$i = 1;
foreach($params as $param) {
$tableName = $param['table'];
$columnName = $param['column'];
$value = $param['value'];
if ($value === null) {
$stmt->setNull($i++);
} else {
$cMap = $dbMap->getTable($tableName)->getColumn($columnName);
$setter = 'set' . CreoleTypes::getAffix($cMap->getCreoleType());
$stmt->$setter($i++, $value);
}
} // foreach
}
/**
* This function searches for the given validator $name under propel/validator/$name.php,
* imports and caches it.
*
* @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator)
* @return Validator object or null if not able to instantiate validator class (and error will be logged in this case)
*/
public static function getValidator($classname)
{
try {
$v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null;
if ($v === null) {
$cls = Propel::import($classname);
$v = new $cls();
self::$validatorMap[$classname] = $v;
}
return $v;
} catch (Exception $e) {
Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": ".$e->getMessage(), Propel::LOG_ERR);
}
}
/**
* This method returns the MapBuilder specified in the name
* parameter. You should pass in the full dot-path path to the class, ie:
* myapp.propel.MyMapMapBuilder. The MapBuilder instances are cached in
* this class for speed.
*
* @param string $classname The dot-path name of class (e.g. myapp.propel.MyMapBuilder)
* @return MapBuilder or null (and logs the error) if the MapBuilder was not found.
* @todo -cBasePeer Consider adding app-level caching support for map builders.
*/
public static function getMapBuilder($classname)
{
try {
$mb = isset(self::$mapBuilders[$classname]) ? self::$mapBuilders[$classname] : null;
if ($mb === null) {
$cls = Propel::import($classname);
$mb = new $cls();
self::$mapBuilders[$classname] = $mb;
}
if (!$mb->isBuilt()) {
$mb->doBuild();
}
return $mb;
} catch (Exception $e) {
// Have to catch possible exceptions because method is
// used in initialization of Peers. Log the exception and
// return null.
Propel::log("BasePeer::getMapBuilder() failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR);
}
}
}

1730
lib/symfony/vendor/propel/util/Criteria.php vendored Executable file

File diff suppressed because it is too large Load Diff

188
lib/symfony/vendor/propel/util/PeerInfo.php vendored Executable file
View File

@ -0,0 +1,188 @@
<?php
/*
* $Id: PeerInfo.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* Peer Helper Class
*
* Handle Dynamic Peer Access. Trying to solve the problems associated
* with looking at constants, calling methods on static Peer Objects
*
* @author David Giffin <david@giffin.org>
* @copyright Copyright (c) 2000-2003 David Giffin : LGPL - See LICENCE
* @package propel.util
*/
class PeerInfo
{
/** Propel Object Peers */
private static $peers = array();
/** Reflection Objects of the Propel Peers */
private static $reflections = array();
/** Table Maps of the Propel Peers */
private static $maps = array();
/**
* Add a Peer to the list of Peers
*
* @param string $peer The Propel Peer to add
*/
private static function addPeer($peer)
{
$peers = array_keys(self::$peers);
if (!in_array($peer, $peers)) {
self::$peers[$peer] = self::loadPeer($peer);
self::$reflections[$peer] = new reflectionClass($peer);
self::$maps[$peer] = null;
}
}
/**
* Get a constant from the Peer Reflector
*
* @param String The name of the constant
* @return String The Constant String
*/
public static function getPeerConstant($peer, $name)
{
self::addPeer($peer);
return self::$reflections[$peer]->getConstant($name);
}
/**
* Get a Peer from the Peer List
*
* @param string $peer The Propel Peer to add
*/
public static function getPeer($peer) {
self::addPeer($peer);
return self::$peers[$peer];
}
/**
* Load a Peer
*
* You may wat to override this method if your Peers
* are not in the include_path.
*
* @param string $peerName the name of the Peer
*/
public static function loadPeer($peerName)
{
$peerFile = $peerName . ".php";
require_once($peerFile);
$peerObject = new $peerName();
return $peerObject;
}
/**
* Get a Column Constant from a Peer
*
* @param string The PhpName or DB_NAME for the constant
* @return string the Column Constant
*/
public static function getColumnConstant($peer, $name)
{
self::addPeer($peer);
$map = self::getPeer($peer)->getPhpNameMap();
foreach ($map as $phpName => $dbName) {
if ($phpName == $name) {
return self::getPeerConstant($peer, $dbName);
} else if ($dbName == $name) {
return self::getPeerConstant($peer, $dbName);
}
}
return null;
}
/**
* Get the Primary Key for this Peer
*
* @param string $peer The name of the Peer
* @return string The name of the Primary Key
*/
public static function getPrimaryKey($peer)
{
self::addPeer($peer);
$tableMap = self::getTableMap($peer);
$columns = $tableMap->getColumns();
foreach ($columns as $columnName => $column) {
if ($column->isPrimaryKey()) {
return $columnName;
}
}
return null;
}
/**
* Get the Table Map for a Peer
*
* @param string $peer The name of the Peer
* @return TableMap The table map for this Peer
*/
public static function getTableMap($peer)
{
self::addPeer($peer);
if (!self::$maps[$peer]) {
$tableName = self::getTableName($peer);
$dbMap = self::getPeer($peer)->getMapBuilder()->getDatabaseMap();
self::$maps[$peer] = $dbMap->getTable($tableName);
}
return self::$maps[$peer];
}
public static function getTableName($peer)
{
self::addPeer($peer);
return self::getPeerConstant($peer, "TABLE_NAME");
}
/**
* Call a Method from the Static Peer Class
*
* @param string $peer The name of the Peer
* @param string $method The name of the method to call
* @param array $params The parameters to pass to the method
* @return mixed What ever the method returns
*/
public static function callMethod($peer, $method, $params = null)
{
if ($params !== null) {
return call_user_func_array(array($peer, $method), $params);
}
return call_user_func(array($peer, $method));
}
}

543
lib/symfony/vendor/propel/util/PropelPager.php vendored Executable file
View File

@ -0,0 +1,543 @@
<?php
/*
* $Id: PropelPager.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* PropelPager
*
* Example Usage:
*
* require_once 'propel/util/PropelPager.php';
* require_once 'PEACH/Propel/Poem/poemPeer.php';
*
* $c = new Criteria();
* $c->addDescendingOrderByColumn(poemPeer::SID);
*
* // with join
* $pager = new PropelPager($c, 'poemPeer', 'doSelectJoinPoemUsers', 1, 50);
*
* // without Join
*
* $pager = new PropelPager($c, 'poemPeer', 'doSelect', 1, 50);
*
* Some template:
*
* <p>
* Total Pages: <?=$pager->getTotalPages()?> Total Records: <?=$pager->getTotalRecordCount()?>
* </p>
* <table>
* <tr>
* <td>
* <?if($link = $pager->getFirstPage):?>
* <a href="somescript?page=<?=$link?>"><?=$link?></a>|
* <?endif?>
* </td>
* <td>
* <?if($link = $pager->getPrev()):?>
* <a href="somescript?page=<?=$link?>">Previous</a>|
* <?endif?>
* </td>
* <td>
* <?foreach($pager->getPrevLinks() as $link):?>
* <a href="somescript?page=<?=$link?>"><?=$link?></a>|
* <?endforeach?>
* </td>
* <td><?=$pager->getPage()?></td>
* <td>
* <?foreach($pager->getNextLinks() as $link):?>
* | <a href="somescript?page=<?=$link?>"><?=$link?></a>
* <?endforeach?>
* </td>
* <td>
* <?if($link = $pager->getNext()):?>
* <a href="somescript?page=<?=$link?>">Last</a>|
* <?endif?>
* </td>
* <td>
* <?if($link = $pager->getLastPage()):?>
* <a href="somescript?page=<?=$link?>"><?=$link?></a>|
* <?endif?>
* </td>
* </tr>
* </table>
* <table id="latestPoems">
* <tr>
* <th>Title</th>
* <th>Auteur</th>
* <th>Date</th>
* <th>comments</th>
* </tr>
* <?foreach($pager->getResult() as $poem):?>
* <tr>
* <td><?=$poem->getTitle()?></td>
* <td><?=$poem->getPoemUsers()->getUname()?></td>
* <td><?=$poem->getTime()?></td>
* <td><?=$poem->getComments()?></td>
* </tr>
* <?endforeach?>
* </table>
*
*
* @author Rob Halff <info@rhalff.com>
* @version $Revision: 536 $
* @copyright Copyright (c) 2004 Rob Halff: LGPL - See LICENCE
* @package propel.util
*/
class PropelPager {
private $recordCount;
private $pages;
private $peerClass;
private $peerSelectMethod;
private $peerCountMethod;
private $criteria;
private $countCriteria;
private $page;
private $rs = null;
/** @var int Start row (offset) */
protected $start = 0;
/** @var int Max rows to return (0 means all) */
protected $max = 0;
/**
* Create a new Propel Pager.
* @param Criteria $c
* @param string $peerClass The name of the static Peer class.
* @param string $peerSelectMethod The name of the static method for selecting content from the Peer class.
* @param int $page The current page (1-based).
* @param int $rowsPerPage The number of rows that should be displayed per page.
*/
public function __construct($c = null, $peerClass = null, $peerSelectMethod = null, $page = 1, $rowsPerPage = 25)
{
if(!isset($c)) {
$c = new Criteria();
}
$this->setCriteria($c);
$this->setPeerClass($peerClass);
$this->setPeerSelectMethod($peerSelectMethod);
$this->guessPeerCountMethod();
$this->setPage($page);
$this->setRowsPerPage($rowsPerPage);
}
/**
* Set the criteria for this pager.
* @param Criteria $c
* @return void
*/
public function setCriteria(Criteria $c)
{
$this->criteria = $c;
}
/**
* Return the Criteria object for this pager.
* @return Criteria
*/
public function getCriteria()
{
return $this->criteria;
}
/**
* Set the Peer Classname
*
* @param string $class
* @return void
*/
public function setPeerClass($class)
{
$this->peerClass = $class;
}
/**
* Return the Peer Classname.
* @return string
*/
public function getPeerClass()
{
return $this->peerClass;
}
/**
* Set the Peer select method.
* This exists for legacy support, please use setPeerSelectMethod().
* @param string $method The name of the static method to call on the Peer class.
* @return void
* @see setPeerSelectMethod()
* @deprecated
*/
public function setPeerMethod($method)
{
$this->setPeerSelectMethod($method);
}
/**
* Return the Peer select method.
* This exists for legacy support, please use getPeerSelectMethod().
* @return string
* @see getPeerSelectMethod()
* @deprecated
*/
public function getPeerMethod()
{
return $this->getPeerSelectMethod();
}
/**
* Set the Peer select method.
*
* @param string $method The name of the static method to call on the Peer class.
* @return void
*/
public function setPeerSelectMethod($method)
{
$this->peerSelectMethod = $method;
}
/**
* Return the Peer select method.
* @return string
*/
public function getPeerSelectMethod()
{
return $this->peerSelectMethod;
}
/**
* Sets the Count method.
* This is set based on the Peer method, for example if Peer method is doSelectJoin*() then the
* count method will be doCountJoin*().
* @param string $method The name of the static method to call on the Peer class.
*/
public function setPeerCountMethod($method)
{
$this->peerCountMethod = $method;
}
/**
* Return the Peer count method.
*/
public function getPeerCountMethod()
{
return $this->peerCountMethod;
}
/**
* Guesses the Peer count method based on the select method.
*/
private function guessPeerCountMethod()
{
$selectMethod = $this->getPeerSelectMethod();
if ($selectMethod == 'doSelect') {
$countMethod = 'doCount';
} elseif ( ($pos = stripos($selectMethod, 'doSelectJoin')) === 0) {
$countMethod = 'doCount' . substr($selectMethod, strlen('doSelect'));
} else {
// we will fall back to doCount() if we don't understand the join
// method; however, it probably won't be accurate. Maybe triggering an error would
// be appropriate ...
$countMethod = 'doCount';
}
$this->setPeerCountMethod($countMethod);
}
/**
* Get the paged resultset
*
* @return mixed $rs
*/
public function getResult()
{
if(!isset($this->rs)) {
$this->doRs();
}
return $this->rs;
}
/**
* Get the paged resultset
*
* Main method which creates a paged result set based on the criteria
* and the requested peer select method.
*
*/
private function doRs()
{
$this->criteria->setOffset($this->start);
$this->criteria->setLimit($this->max);
$this->rs = call_user_func(array($this->getPeerClass(), $this->getPeerSelectMethod()), $this->criteria);
}
/**
* Get the first page
*
* For now I can only think of returning 1 always.
* It should probably return 0 if there are no pages
*
* @return int 1
*/
public function getFirstPage()
{
return '1';
}
/**
* Convenience method to indicate whether current page is the first page.
*
* @return boolean
*/
public function atFirstPage()
{
return $this->getPage() == $this->getFirstPage();
}
/**
* Get last page
*
* @return int $lastPage
*/
public function getLastPage()
{
$totalPages = $this->getTotalPages();
if ($totalPages == 0) {
return 1;
} else {
return $totalPages;
}
}
/**
* Convenience method to indicate whether current page is the last page.
*
* @return boolean
*/
public function atLastPage()
{
return $this->getPage() == $this->getLastPage();
}
/**
* get total pages
*
* @return int $this->pages
*/
public function getTotalPages() {
if(!isset($this->pages)) {
$recordCount = $this->getTotalRecordCount();
if($this->max > 0) {
$this->pages = ceil($recordCount/$this->max);
} else {
$this->pages = 0;
}
}
return $this->pages;
}
/**
* get an array of previous id's
*
* @param int $range
* @return array $links
*/
public function getPrevLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() - 1;
$end = $this->getPage() - $range;
$first = $this->getFirstPage();
$links = array();
for($i=$start; $i>$end; $i--) {
if($i < $first) {
break;
}
$links[] = $i;
}
return array_reverse($links);
}
/**
* get an array of next id's
*
* @param int $range
* @return array $links
*/
public function getNextLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() + 1;
$end = $this->getPage() + $range;
$last = $this->getLastPage();
$links = array();
for($i=$start; $i<$end; $i++) {
if($i > $last) {
break;
}
$links[] = $i;
}
return $links;
}
/**
* Returns whether last page is complete
*
* @return bool Last page complete or not
*/
public function isLastPageComplete()
{
return !($this->getTotalRecordCount() % $this->max);
}
/**
* get previous id
*
* @return mixed $prev
*/
public function getPrev() {
if($this->getPage() != $this->getFirstPage()) {
$prev = $this->getPage() - 1;
} else {
$prev = false;
}
return $prev;
}
/**
* get next id
*
* @return mixed $next
*/
public function getNext() {
if($this->getPage() != $this->getLastPage()) {
$next = $this->getPage() + 1;
} else {
$next = false;
}
return $next;
}
/**
* Set the current page number (First page is 1).
* @param int $page
* @return void
*/
public function setPage($page)
{
$this->page = $page;
// (re-)calculate start rec
$this->calculateStart();
}
/**
* Get current page.
* @return int
*/
public function getPage()
{
return $this->page;
}
/**
* Set the number of rows per page.
* @param int $r
*/
public function setRowsPerPage($r)
{
$this->max = $r;
// (re-)calculate start rec
$this->calculateStart();
}
/**
* Get number of rows per page.
* @return int
*/
public function getRowsPerPage()
{
return $this->max;
}
/**
* Calculate startrow / max rows based on current page and rows-per-page.
* @return void
*/
private function calculateStart()
{
$this->start = ( ($this->page - 1) * $this->max );
}
/**
* Gets the total number of (un-LIMITed) records.
*
* This method will perform a query that executes un-LIMITed query.
*
* @return int Total number of records - disregarding page, maxrows, etc.
*/
public function getTotalRecordCount()
{
if(!isset($this->rs)) {
$this->doRs();
}
if(empty($this->recordCount)) {
$this->countCriteria = clone $this->criteria;
$this->countCriteria->setLimit(0);
$this->countCriteria->setOffset(0);
$this->recordCount = call_user_func(
array(
$this->getPeerClass(),
$this->getPeerCountMethod()
),
$this->countCriteria
);
}
return $this->recordCount;
}
/**
* Sets the start row or offset.
* @param int $v
*/
public function setStart($v)
{
$this->start = $v;
}
/**
* Sets max rows (limit).
* @param int $v
* @return void
*/
public function setMax($v)
{
$this->max = $v;
}
}

160
lib/symfony/vendor/propel/util/Transaction.php vendored Executable file
View File

@ -0,0 +1,160 @@
<?php
/*
* $Id: Transaction.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* Utility class to make it easier to begin, commit, and rollback transactions.
*
* This can be used to handle cases where transaction support is optional.
* The second parameter of beginOptionalTransaction() will determine with a transaction
* is used or not. If a transaction is not used, the commit and rollback methods
* do not have any effect. Instead it simply makes the logic easier to follow
* by cutting down on the if statements based solely on whether a transaction
* is needed or not.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Stephen Haberman <stephenh@chase3000.com> (Torque)
* @version $Revision: 536 $
* @package propel.util
*/
class Transaction {
/**
* Begin a transaction. This method will fallback gracefully to
* return a normal connection, if the database being accessed does
* not support transactions.
*
* @param string $dbName Name of database.
* @return Connection The Connection for the transaction.
* @throws PropelException
*/
public static function begin($dbName)
{
$con = Propel::getConnection($dbName);
try {
$con->setAutoCommit(false);
} catch (SQLException $e) {
throw new PropelException($e);
}
return $con;
}
/**
* Begin a transaction. This method will fallback gracefully to
* return a normal connection, if the database being accessed does
* not support transactions.
*
* @param sring $dbName Name of database.
* @param boolean $useTransaction If false, a transaction won't be used.
* @return Connection The Connection for the transaction.
* @throws PropelException
*/
public static function beginOptional($dbName, $useTransaction)
{
$con = Propel::getConnection($dbName);
try {
if ($useTransaction) {
$con->setAutoCommit(false);
}
} catch (SQLException $e) {
throw new PropelException($e);
}
return $con;
}
/**
* Commit a transaction. This method takes care of releasing the
* connection after the commit. In databases that do not support
* transactions, it only returns the connection.
*
* @param Connection $con The Connection for the transaction.
* @return void
* @throws PropelException
*/
public static function commit($con)
{
if ($con === null) {
throw new PropelException(
"Connection object was null. "
. "This could be due to a misconfiguration. "
. "Check the logs and Propel properties "
. "to better determine the cause.");
}
try {
if ($con->getAutoCommit() === false) {
$con->commit();
$con->setAutoCommit(true);
}
} catch (SQLException $e) {
throw new PropelException($e);
}
}
/**
* Roll back a transaction in databases that support transactions.
* It also releases the connection. In databases that do not support
* transactions, this method will log the attempt and release the
* connection.
*
* @param Connection $con The Connection for the transaction.
* @return void
* @throws PropelException
*/
public static function rollback($con)
{
if ($con === null) {
throw new PropelException(
"Connection object was null. "
. "This could be due to a misconfiguration. "
. "Check the logs and Propel properties "
. "to better determine the cause.");
}
try {
if ($con->getAutoCommit() === false) {
$con->rollback();
$con->setAutoCommit(true);
}
} catch (SQLException $e) {
Propel::log(
"An attempt was made to rollback a transaction "
. "but the database did not allow the operation to be "
. "rolled back: " . $e->getMessage(), Propel::LOG_ERR);
throw new PropelException($e);
}
}
/**
* Roll back a transaction without throwing errors if they occur.
*
* @param Connection $con The Connection for the transaction.
* @return void
*/
public static function safeRollback($con)
{
try {
Transaction::rollback($con);
} catch (PropelException $e) {
Propel::log("An error occured during rollback: " . $e->getMessage(), Propel::LOG_ERR);
}
}
}

View File

@ -0,0 +1,46 @@
<?php
/*
* $Id: BasicValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* Basic Validator interface.
*
* BasicValidator objects perform validation without any knowledge of column/table
* context. They are simply given an input and some value and asked whether the input
* is valid.
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
interface BasicValidator
{
/**
* Determine whether a value meets the criteria specified
*
* @param ValidatorMap $map A column map object for the column to be validated.
* @param string $str a <code>String</code> to be tested
*
* @return mixed TRUE if valid, error message otherwise
*/
public function isValid(ValidatorMap $map, $str);
}

View File

@ -0,0 +1,81 @@
<?php
/*
* $Id: MatchValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for regular expressions.
*
* This validator will return true, when the passed value *matches* the
* regular expression.
*
* ## This class replaces the former class MaskValidator ##
*
* If you do want to test if the value does *not* match an expression,
* you can use the MatchValidator class instead.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="email" type="VARCHAR" size="128" required="true" />
* <validator column="username">
* <!-- allow strings that match the email adress pattern -->
* <rule
* name="match"
* value="/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/"
* message="Please enter a valid email address." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.validator
*/
class MatchValidator implements BasicValidator
{
/**
* Prepares the regular expression entered in the XML
* for use with preg_match().
* @param string $exp
* @return string Prepared regular expession.
*/
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) {
$exp = '/' . $exp . '/';
}
// if they did not escape / chars; we do that for them
$exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp);
return $exp;
}
/**
* Whether the passed string matches regular expression.
*/
public function isValid (ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0);
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
* $Id: MaxLengthValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for maximum string length.
*
* Below is an example usage for your Propel xml schema file.
*
* Note that if you have specified the size attribute in the column tag
* you do not have to specify it as value in the validator rule again as
* this is done automatically.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="maxLength" message="Passwort must be at least ${value} characters !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class MaxLengthValidator implements BasicValidator
{
public function isValid (ValidatorMap $map, $str)
{
return strlen($str) <= intval($map->getValue());
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
* $Id: MaxValueValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for maximum values.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="articles" type="INTEGER" required="true" />
*
* <validator column="articles">
* <rule name="minValue" value="1" message="Minimum value for selected articles is ${value} !" />
* <rule name="maxValue" value="10" message="Maximum value for selected articles is ${value} !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class MaxValueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $value)
{
if(is_null($value) == false && is_numeric($value) == true) {
return intval($value) <= intval($map->getValue());
}
return false;
}
}

View File

@ -0,0 +1,49 @@
<?php
/*
* $Id: MinLengthValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for minimum string length.
*
* <code>
* <column name="password" type="VARCHAR" size="34" required="true" />
*
* <validator column="password">
* <rule name="minLength" value="5" message="Passwort must be at least ${value} characters !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class MinLengthValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
return strlen($str) >= intval($map->getValue());
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
* $Id: MinValueValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for minimum values.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="articles" type="INTEGER" required="true" />
*
* <validator column="articles">
* <rule name="minValue" value="1" message="Minimum value for selected articles is ${value} !" />
* <rule name="maxValue" value="10" message="Maximum value for selected articles is ${value} !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class MinValueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $value)
{
if(is_null($value) == false && is_numeric($value)) {
return intval($value) >= intval($map->getValue());
}
return false;
}
}

View File

@ -0,0 +1,79 @@
<?php
/*
* $Id: NotMatchValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for regular expressions.
*
* This validator will return true, when the passed value does *not* match
* the regular expression.
*
* If you do want to test if the value *matches* an expression, you can use
* the MatchValidator class instead.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="ISBN" type="VARCHAR" size="20" required="true" />
* <validator column="username">
* <!-- disallow everything that's not a digit or minus -->
* <rule
* name="notMatch"
* value="/[^\d-]+/"
* message="Please enter a valid email adress." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.validator
*/
class NotMatchValidator implements BasicValidator
{
/**
* Prepares the regular expression entered in the XML
* for use with preg_match().
* @param string $exp
* @return string Prepared regular expession.
*/
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) {
$exp = '/' . $exp . '/';
}
// if they did not escape / chars; we do that for them
$exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp);
return $exp;
}
/**
* Whether the passed string matches regular expression.
*/
public function isValid (ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0);
}
}

View File

@ -0,0 +1,51 @@
<?php
/*
* $Id: RequiredValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for required fields.
*
* Below is an example usage for your Propel xml schema file.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="required" message="Username is required." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class RequiredValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
return ($str !== null && $str !== "");
}
}

View File

@ -0,0 +1,66 @@
<?php
/*
* $Id: UniqueValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for unique column names.
*
* <code>
* <column name="username" type="VARCHAR" size="25" required="true" />
*
* <validator column="username">
* <rule name="unique" message="Username already exists !" />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class UniqueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
$column = $map->getColumn();
$c = new Criteria();
$c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL);
$isValid = false;
try {
$table = $column->getTable()->getPhpName();
$cmd = sprintf('$isValid = %sPeer::doCount($c) == 0;', $table);
eval($cmd);
} catch(PropelException $e) {
/* what to do here ? */
}
return $isValid;
}
}

View File

@ -0,0 +1,46 @@
<?php
/*
* $Id: ValidValuesValidator.php 536 2007-01-10 14:30:38Z 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>.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for valid values (e.g. for enum fields)
*
* <code>
* <column name="address_type" type="VARCHAR" required="true" default="delivery" />
*
* <validator column="address_type">
* <rule name="validValues" value="account|delivery" message="Please select a valid address type." />
* </validator>
* </code>
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.validator
*/
class ValidValuesValidator implements BasicValidator
{
public function isValid (ValidatorMap $map, $str)
{
return in_array($str, explode("|", $map->getValue()));
}
}

View File

@ -0,0 +1,126 @@
<?php
/*
* $Id: ValidationFailed.php 536 2007-01-10 14:30:38Z 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>.
*/
/**
* Simple class that serves as a container for any information about a failed validation.
*
* Currently this class stores the qualified column name (e.g. tablename.COLUMN_NAME) and
* the message that should be displayed to the user.
*
* An array of these objects will be returned by BasePeer::doValidate() if validation
* failed.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 536 $
* @package propel.validator
* @see BasePeer::doValidate()
*/
class ValidationFailed {
/** Column name in tablename.COLUMN_NAME format */
private $colname;
/** Message to display to user. */
private $message;
/** Validator object that caused this to fail. */
private $validator;
/**
* Construct a new ValidationFailed object.
* @param string $colname Column name.
* @param string $message Message to display to user.
* @param object $validator The Validator that caused this column to fail.
*/
public function __construct($colname, $message, $validator = null)
{
$this->colname = $colname;
$this->message = $message;
$this->validator = $validator;
}
/**
* Set the column name.
* @param string $v
*/
public function setColumn($v)
{
$this->colname = $v;
}
/**
* Gets the column name.
* @return string Qualified column name (tablename.COLUMN_NAME)
*/
public function getColumn()
{
return $this->colname;
}
/**
* Set the message for the validation failure.
* @param string $v
*/
public function setMessage($v)
{
$this->message = $v;
}
/**
* Gets the message for the validation failure.
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* Set the validator object that caused this to fail.
* @param object $v
*/
public function setValidator($v)
{
$this->validator = $v;
}
/**
* Gets the validator object that caused this to fail.
* @return object
*/
public function getValidator()
{
return $this->validator;
}
/**
* "magic" method to get string represenation of object.
* Maybe someday PHP5 will support the invoking this method automatically
* on (string) cast. Until then it's pretty useless.
* @return string
*/
public function __toString()
{
return $this->getMessage();
}
}