111 lines
2.7 KiB
PHP
111 lines
2.7 KiB
PHP
<?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';
|
|
}
|
|
}
|