adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
299
library/propel/generator/lib/platform/DefaultPlatform.php
Normal file
299
library/propel/generator/lib/platform/DefaultPlatform.php
Normal file
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/Platform.php';
|
||||
require_once 'model/Domain.php';
|
||||
require_once 'model/PropelTypes.php';
|
||||
|
||||
/**
|
||||
* Default implementation for the Platform interface.
|
||||
*
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class DefaultPlatform implements Platform
|
||||
{
|
||||
|
||||
/**
|
||||
* Mapping from Propel types to Domain objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $schemaDomainMap;
|
||||
|
||||
/**
|
||||
* GeneratorConfig object holding build properties.
|
||||
*
|
||||
* @var GeneratorConfig
|
||||
*/
|
||||
private $generatorConfig;
|
||||
|
||||
/**
|
||||
* @var PDO Database connection.
|
||||
*/
|
||||
private $con;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* @param PDO $con Optional database connection to use in this platform.
|
||||
*/
|
||||
public function __construct(PDO $con = null)
|
||||
{
|
||||
if ($con) $this->setConnection($con);
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the database connection to use for this Platform class.
|
||||
* @param PDO $con Database connection to use in this platform.
|
||||
*/
|
||||
public function setConnection(PDO $con = null)
|
||||
{
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GeneratorConfig to use in the parsing.
|
||||
*
|
||||
* @param GeneratorConfig $config
|
||||
*/
|
||||
public function setGeneratorConfig(GeneratorConfig $config)
|
||||
{
|
||||
$this->generatorConfig = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GeneratorConfig option.
|
||||
*
|
||||
* @return GeneratorConfig
|
||||
*/
|
||||
public function getGeneratorConfig()
|
||||
{
|
||||
return $this->generatorConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a specific propel (renamed) property from the build.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getBuildProperty($name)
|
||||
{
|
||||
if ($this->generatorConfig !== null) {
|
||||
return $this->generatorConfig->getBuildProperty($name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database connection to use for this Platform class.
|
||||
* @return PDO The database connection or NULL if none has been set.
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->con;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the type -> Domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->schemaDomainMap = array();
|
||||
foreach (PropelTypes::getPropelTypes() as $type) {
|
||||
$this->schemaDomainMap[$type] = new Domain($type);
|
||||
}
|
||||
// BU_* no longer needed, so map these to the DATE/TIMESTAMP domains
|
||||
$this->schemaDomainMap[PropelTypes::BU_DATE] = new Domain(PropelTypes::DATE);
|
||||
$this->schemaDomainMap[PropelTypes::BU_TIMESTAMP] = new Domain(PropelTypes::TIMESTAMP);
|
||||
|
||||
// Boolean is a bit special, since typically it must be mapped to INT type.
|
||||
$this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN, "INTEGER");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping entry for specified Domain.
|
||||
* @param Domain $domain
|
||||
*/
|
||||
protected function setSchemaDomainMapping(Domain $domain)
|
||||
{
|
||||
$this->schemaDomainMap[$domain->getType()] = $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the short name of the database type that this platform represents.
|
||||
* For example MysqlPlatform->getDatabaseType() returns 'mysql'.
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabaseType()
|
||||
{
|
||||
$clazz = get_class($this);
|
||||
$pos = strpos($clazz, 'Platform');
|
||||
return strtolower(substr($clazz,0,$pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getNativeIdMethod()
|
||||
*/
|
||||
public function getNativeIdMethod()
|
||||
{
|
||||
return Platform::IDENTITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getDomainForType()
|
||||
*/
|
||||
public function getDomainForType($propelType)
|
||||
{
|
||||
if (!isset($this->schemaDomainMap[$propelType])) {
|
||||
throw new EngineException("Cannot map unknown Propel type " . var_export($propelType, true) . " to native database type.");
|
||||
}
|
||||
return $this->schemaDomainMap[$propelType];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Returns the SQL fragment to use if null values are disallowed.
|
||||
* @see Platform::getNullString(boolean)
|
||||
*/
|
||||
public function getNullString($notNull)
|
||||
{
|
||||
return ($notNull ? "NOT NULL" : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getAutoIncrement()
|
||||
*/
|
||||
public function getAutoIncrement()
|
||||
{
|
||||
return "IDENTITY";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::hasScale(String)
|
||||
*/
|
||||
public function hasScale($sqlType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::hasSize(String)
|
||||
*/
|
||||
public function hasSize($sqlType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::quote()
|
||||
*/
|
||||
public function quote($text)
|
||||
{
|
||||
if ($this->getConnection()) {
|
||||
return $this->getConnection()->quote($text);
|
||||
} else {
|
||||
return "'" . $this->disconnectedEscapeText($text) . "'";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to escape text when no connection has been set.
|
||||
*
|
||||
* The subclasses can implement this using string replacement functions
|
||||
* or native DB methods.
|
||||
*
|
||||
* @param string $text Text that needs to be escaped.
|
||||
* @return string
|
||||
*/
|
||||
protected function disconnectedEscapeText($text)
|
||||
{
|
||||
return str_replace("'", "''", $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::quoteIdentifier()
|
||||
*/
|
||||
public function quoteIdentifier($text)
|
||||
{
|
||||
return '"' . $text . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsNativeDeleteTrigger()
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsInsertNullPk()
|
||||
*/
|
||||
public function supportsInsertNullPk()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasStreamBlobImpl()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getBooleanString()
|
||||
*/
|
||||
public function getBooleanString($b)
|
||||
{
|
||||
$b = ($b === true || strtolower($b) === 'true' || $b === 1 || $b === '1' || strtolower($b) === 'y' || strtolower($b) === 'yes');
|
||||
return ($b ? '1' : '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred timestamp formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestampFormatter()
|
||||
{
|
||||
return DateTime::ISO8601;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred time formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimeFormatter()
|
||||
{
|
||||
return 'H:i:s';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred date formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormatter()
|
||||
{
|
||||
return 'Y-m-d';
|
||||
}
|
||||
|
||||
}
|
107
library/propel/generator/lib/platform/MssqlPlatform.php
Normal file
107
library/propel/generator/lib/platform/MssqlPlatform.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/DefaultPlatform.php';
|
||||
require_once 'model/Domain.php';
|
||||
|
||||
/**
|
||||
* MS SQL Platform implementation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org> (Propel)
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class MssqlPlatform extends DefaultPlatform
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes db specific domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, "INT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, "INT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "FLOAT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "TEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BU_DATE, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BU_TIMESTAMP, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BINARY(7132)"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "IMAGE"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "IMAGE"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "IMAGE"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Explicitly returns <code>NULL</code> if null values are
|
||||
* allowed (as recomended by Microsoft).
|
||||
* @see Platform#getNullString(boolean)
|
||||
*/
|
||||
public function getNullString($notNull)
|
||||
{
|
||||
return ($notNull ? "NOT NULL" : "NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsNativeDeleteTrigger()
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsInsertNullPk()
|
||||
*/
|
||||
public function supportsInsertNullPk()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::hasSize(String)
|
||||
*/
|
||||
public function hasSize($sqlType)
|
||||
{
|
||||
return !("INT" == $sqlType || "TEXT" == $sqlType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::quoteIdentifier()
|
||||
*/
|
||||
public function quoteIdentifier($text)
|
||||
{
|
||||
return '[' . $text . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred timestamp formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestampFormatter()
|
||||
{
|
||||
return 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
|
||||
}
|
110
library/propel/generator/lib/platform/MysqlPlatform.php
Normal file
110
library/propel/generator/lib/platform/MysqlPlatform.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/DefaultPlatform.php';
|
||||
|
||||
/**
|
||||
* MySql Platform implementation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org> (Propel)
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class MysqlPlatform extends DefaultPlatform
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes db specific domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, "TINYINT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "DATETIME"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getAutoIncrement()
|
||||
*/
|
||||
public function getAutoIncrement()
|
||||
{
|
||||
return "AUTO_INCREMENT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsNativeDeleteTrigger()
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger()
|
||||
{
|
||||
$usingInnoDB = false;
|
||||
if (class_exists('DataModelBuilder', false))
|
||||
{
|
||||
$usingInnoDB = strtolower($this->getBuildProperty('mysqlTableType')) == 'innodb';
|
||||
}
|
||||
return $usingInnoDB || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#hasSize(String)
|
||||
*/
|
||||
public function hasSize($sqlType)
|
||||
{
|
||||
return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType
|
||||
|| "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType
|
||||
|| "LONGBLOB" == $sqlType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the string for RDBMS.
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function disconnectedEscapeText($text)
|
||||
{
|
||||
if (function_exists('mysql_escape_string')) {
|
||||
return mysql_escape_string($text);
|
||||
} else {
|
||||
return addslashes($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::quoteIdentifier()
|
||||
*/
|
||||
public function quoteIdentifier($text)
|
||||
{
|
||||
return '`' . $text . '`';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred timestamp formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestampFormatter()
|
||||
{
|
||||
return 'Y-m-d H:i:s';
|
||||
}
|
||||
}
|
113
library/propel/generator/lib/platform/OraclePlatform.php
Normal file
113
library/propel/generator/lib/platform/OraclePlatform.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/DefaultPlatform.php';
|
||||
|
||||
/**
|
||||
* Oracle Platform implementation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org> (Propel)
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class OraclePlatform extends DefaultPlatform
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes db specific domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN_EMU, "NUMBER", "1", "0");
|
||||
$this->schemaDomainMap[PropelTypes::CLOB] = new Domain(PropelTypes::CLOB_EMU, "CLOB");
|
||||
$this->schemaDomainMap[PropelTypes::CLOB_EMU] = $this->schemaDomainMap[PropelTypes::CLOB];
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, "NUMBER", "3", "0"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, "NUMBER", "5", "0"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, "NUMBER"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, "NUMBER", "20", "0"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, "NUMBER"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "FLOAT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, "NUMBER"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "NUMBER"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARCHAR, "NVARCHAR2"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "NVARCHAR2", "2000"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, "DATE"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATE"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "TIMESTAMP"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "LONG RAW"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "BLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONG RAW"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getNativeIdMethod()
|
||||
*/
|
||||
public function getNativeIdMethod()
|
||||
{
|
||||
return Platform::SEQUENCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getAutoIncrement()
|
||||
*/
|
||||
public function getAutoIncrement()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsNativeDeleteTrigger()
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasStreamBlobImpl()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quotes identifiers used in database SQL.
|
||||
* @see Platform::quoteIdentifier()
|
||||
* @param string $text
|
||||
* @return string Quoted identifier.
|
||||
*/
|
||||
public function quoteIdentifier($text)
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred timestamp formatter for setting date/time values.
|
||||
* @see Platform::getTimestampFormatter()
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestampFormatter()
|
||||
{
|
||||
return 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
}
|
118
library/propel/generator/lib/platform/PgsqlPlatform.php
Normal file
118
library/propel/generator/lib/platform/PgsqlPlatform.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/DefaultPlatform.php';
|
||||
|
||||
/**
|
||||
* Postgresql Platform implementation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org> (Propel)
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class PgsqlPlatform extends DefaultPlatform
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes db specific domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, "BOOLEAN"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, "INT2"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, "INT2"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, "INT8"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, "FLOAT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "DOUBLE PRECISION"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BYTEA"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "BYTEA"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "BYTEA"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "BYTEA"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "TEXT"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getNativeIdMethod()
|
||||
*/
|
||||
public function getNativeIdMethod()
|
||||
{
|
||||
return Platform::SERIAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getAutoIncrement()
|
||||
*/
|
||||
public function getAutoIncrement()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the string for RDBMS.
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function disconnectedEscapeText($text)
|
||||
{
|
||||
if (function_exists('pg_escape_string')) {
|
||||
return pg_escape_string($text);
|
||||
} else {
|
||||
return parent::disconnectedEscapeText($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::getBooleanString()
|
||||
*/
|
||||
public function getBooleanString($b)
|
||||
{
|
||||
// parent method does the checking for allowes tring
|
||||
// representations & returns integer
|
||||
$b = parent::getBooleanString($b);
|
||||
return ($b ? "'t'" : "'f'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::supportsNativeDeleteTrigger()
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::hasSize(String)
|
||||
* TODO collect info for all platforms
|
||||
*/
|
||||
public function hasSize($sqlType)
|
||||
{
|
||||
return !("BYTEA" == $sqlType || "TEXT" == $sqlType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasStreamBlobImpl()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
182
library/propel/generator/lib/platform/Platform.php
Normal file
182
library/propel/generator/lib/platform/Platform.php
Normal file
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for RDBMS platform specific behaviour.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org> (Propel)
|
||||
* @author Martin Poeschl <mpoeschl@marmot.at> (Torque)
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
interface Platform
|
||||
{
|
||||
|
||||
/**
|
||||
* Constant for auto-increment id method.
|
||||
*/
|
||||
const IDENTITY = "identity";
|
||||
|
||||
/**
|
||||
* Constant for sequence id method.
|
||||
*/
|
||||
const SEQUENCE = "sequence";
|
||||
|
||||
/**
|
||||
* Constant for serial id method (postgresql).
|
||||
*/
|
||||
const SERIAL = "serial";
|
||||
|
||||
/**
|
||||
* Sets a database connection to use (for quoting, etc.).
|
||||
* @param PDO $con The database connection to use in this Platform class.
|
||||
*/
|
||||
public function setConnection(PDO $con = null);
|
||||
|
||||
/**
|
||||
* Returns the database connection to use for this Platform class.
|
||||
* @return PDO The database connection or NULL if none has been set.
|
||||
*/
|
||||
public function getConnection();
|
||||
|
||||
/**
|
||||
* Sets the GeneratorConfig which contains any generator build properties.
|
||||
*
|
||||
* @param GeneratorConfig $config
|
||||
*/
|
||||
public function setGeneratorConfig(GeneratorConfig $config);
|
||||
|
||||
/**
|
||||
* Gets the GeneratorConfig object.
|
||||
*
|
||||
* @return GeneratorConfig
|
||||
*/
|
||||
public function getGeneratorConfig();
|
||||
|
||||
/**
|
||||
* Returns the short name of the database type that this platform represents.
|
||||
* For example MysqlPlatform->getDatabaseType() returns 'mysql'.
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabaseType();
|
||||
|
||||
/**
|
||||
* Returns the native IdMethod (sequence|identity)
|
||||
*
|
||||
* @return string The native IdMethod (Platform:IDENTITY, Platform::SEQUENCE).
|
||||
*/
|
||||
public function getNativeIdMethod();
|
||||
|
||||
/**
|
||||
* Returns the max column length supported by the db.
|
||||
*
|
||||
* @return int The max column length
|
||||
*/
|
||||
public function getMaxColumnNameLength();
|
||||
|
||||
/**
|
||||
* Returns the db specific domain for a propelType.
|
||||
*
|
||||
* @param string $propelType the Propel type name.
|
||||
* @return Domain The db specific domain.
|
||||
*/
|
||||
public function getDomainForType($propelType);
|
||||
|
||||
/**
|
||||
* @return string The RDBMS-specific SQL fragment for <code>NULL</code>
|
||||
* or <code>NOT NULL</code>.
|
||||
*/
|
||||
public function getNullString($notNull);
|
||||
|
||||
/**
|
||||
* @return The RDBMS-specific SQL fragment for autoincrement.
|
||||
*/
|
||||
public function getAutoIncrement();
|
||||
|
||||
/**
|
||||
* Returns if the RDBMS-specific SQL type has a size attribute.
|
||||
*
|
||||
* @param string $sqlType the SQL type
|
||||
* @return boolean True if the type has a size attribute
|
||||
*/
|
||||
public function hasSize($sqlType);
|
||||
|
||||
/**
|
||||
* Returns if the RDBMS-specific SQL type has a scale attribute.
|
||||
*
|
||||
* @param string $sqlType the SQL type
|
||||
* @return boolean True if the type has a scale attribute
|
||||
*/
|
||||
public function hasScale($sqlType);
|
||||
|
||||
/**
|
||||
* Quote and escape needed characters in the string for unerlying RDBMS.
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function quote($text);
|
||||
|
||||
/**
|
||||
* Quotes identifiers used in database SQL.
|
||||
* @param string $text
|
||||
* @return string Quoted identifier.
|
||||
*/
|
||||
public function quoteIdentifier($text);
|
||||
|
||||
/**
|
||||
* Whether RDBMS supports native ON DELETE triggers (e.g. ON DELETE CASCADE).
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportsNativeDeleteTrigger();
|
||||
|
||||
/**
|
||||
* Whether RDBMS supports INSERT null values in autoincremented primary keys
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportsInsertNullPk();
|
||||
|
||||
/**
|
||||
* Returns the boolean value for the RDBMS.
|
||||
*
|
||||
* This value should match the boolean value that is set
|
||||
* when using Propel's PreparedStatement::setBoolean().
|
||||
*
|
||||
* This function is used to set default column values when building
|
||||
* SQL.
|
||||
*
|
||||
* @param mixed $tf A boolean or string representation of boolean ('y', 'true').
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBooleanString($tf);
|
||||
|
||||
/**
|
||||
* Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasStreamBlobImpl();
|
||||
|
||||
/**
|
||||
* Gets the preferred timestamp formatter for setting date/time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestampFormatter();
|
||||
|
||||
/**
|
||||
* Gets the preferred date formatter for setting time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormatter();
|
||||
|
||||
/**
|
||||
* Gets the preferred time formatter for setting time values.
|
||||
* @return string
|
||||
*/
|
||||
public function getTimeFormatter();
|
||||
}
|
87
library/propel/generator/lib/platform/SqlitePlatform.php
Normal file
87
library/propel/generator/lib/platform/SqlitePlatform.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Propel package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
require_once 'platform/DefaultPlatform.php';
|
||||
|
||||
/**
|
||||
* SQLite Platform implementation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1612 $
|
||||
* @package propel.generator.platform
|
||||
*/
|
||||
class SqlitePlatform extends DefaultPlatform
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes db specific domain mapping.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "MEDIUMTEXT"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATETIME"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB"));
|
||||
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getAutoIncrement()
|
||||
* @link http://www.sqlite.org/autoinc.html
|
||||
*/
|
||||
public function getAutoIncrement()
|
||||
{
|
||||
|
||||
return "PRIMARY KEY";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#getMaxColumnNameLength()
|
||||
*/
|
||||
public function getMaxColumnNameLength()
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform#hasSize(String)
|
||||
*/
|
||||
public function hasSize($sqlType) {
|
||||
return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType
|
||||
|| "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType
|
||||
|| "LONGBLOB" == $sqlType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the string for RDBMS.
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function disconnectedEscapeText($text)
|
||||
{
|
||||
if (function_exists('sqlite_escape_string')) {
|
||||
return sqlite_escape_string($text);
|
||||
} else {
|
||||
return parent::disconnectedEscapeText($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Platform::quoteIdentifier()
|
||||
*/
|
||||
public function quoteIdentifier($text)
|
||||
{
|
||||
return '[' . $text . ']';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue