[2.0] Removing old enum stuff
This commit is contained in:
parent
c89d0e6383
commit
e21d8fffae
4 changed files with 0 additions and 305 deletions
|
@ -38,233 +38,7 @@ class PostgreSqlPlatform extends AbstractPlatform
|
|||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
*
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @override
|
||||
*/
|
||||
public function getNativeDeclaration(array $field)
|
||||
{
|
||||
if ( ! isset($field['type'])) {
|
||||
throw DoctrineException::updateMe('Missing column type.');
|
||||
}
|
||||
switch ($field['type']) {
|
||||
case 'char':
|
||||
case 'string':
|
||||
case 'array':
|
||||
case 'object':
|
||||
case 'varchar':
|
||||
case 'gzip':
|
||||
// TODO: what is the maximum VARCHAR length in pgsql ?
|
||||
$length = (isset($field['length']) && $field['length'] && $field['length'] < 10000) ? $field['length'] : null;
|
||||
|
||||
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
|
||||
|
||||
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR('.$this->conn->options['default_text_field_length'].')')
|
||||
: ($length ? 'VARCHAR(' .$length . ')' : 'TEXT');
|
||||
|
||||
case 'clob':
|
||||
return 'TEXT';
|
||||
case 'blob':
|
||||
return 'BYTEA';
|
||||
case 'enum':
|
||||
case 'integer':
|
||||
case 'int':
|
||||
if ( ! empty($field['autoincrement'])) {
|
||||
if ( ! empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length > 4) {
|
||||
return 'BIGSERIAL';
|
||||
}
|
||||
}
|
||||
return 'SERIAL';
|
||||
}
|
||||
if ( ! empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 2) {
|
||||
return 'SMALLINT';
|
||||
} elseif ($length == 3 || $length == 4) {
|
||||
return 'INT';
|
||||
} elseif ($length > 4) {
|
||||
return 'BIGINT';
|
||||
}
|
||||
}
|
||||
return 'INT';
|
||||
case 'boolean':
|
||||
return 'BOOLEAN';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'time':
|
||||
return 'TIME without time zone';
|
||||
case 'timestamp':
|
||||
return 'TIMESTAMP without time zone';
|
||||
case 'float':
|
||||
case 'double':
|
||||
return 'FLOAT';
|
||||
case 'decimal':
|
||||
$length = !empty($field['length']) ? $field['length'] : 18;
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
|
||||
return 'NUMERIC('.$length.','.$scale.')';
|
||||
}
|
||||
throw DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a portable Doctrine datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
*
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @override
|
||||
*/
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
$length = (isset($field['length'])) ? $field['length'] : null;
|
||||
if ($length == '-1' && isset($field['atttypmod'])) {
|
||||
$length = $field['atttypmod'] - 4;
|
||||
}
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
$type = array();
|
||||
$unsigned = $fixed = null;
|
||||
|
||||
if ( ! isset($field['name'])) {
|
||||
$field['name'] = '';
|
||||
}
|
||||
|
||||
$dbType = strtolower($field['type']);
|
||||
|
||||
switch ($dbType) {
|
||||
case 'smallint':
|
||||
case 'int2':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 2;
|
||||
if ($length == '2') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'int':
|
||||
case 'int4':
|
||||
case 'integer':
|
||||
case 'serial':
|
||||
case 'serial4':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 4;
|
||||
break;
|
||||
case 'bigint':
|
||||
case 'int8':
|
||||
case 'bigserial':
|
||||
case 'serial8':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 8;
|
||||
break;
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$type[] = 'boolean';
|
||||
$length = 1;
|
||||
break;
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
case 'interval':
|
||||
case '_varchar':
|
||||
$fixed = false;
|
||||
case 'unknown':
|
||||
case 'char':
|
||||
case 'bpchar':
|
||||
$type[] = 'string';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
} elseif (strstr($dbType, 'text')) {
|
||||
$type[] = 'clob';
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
case 'timestamptz':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'time':
|
||||
$type[] = 'time';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
case 'float4':
|
||||
case 'float8':
|
||||
case 'double':
|
||||
case 'double precision':
|
||||
case 'real':
|
||||
$type[] = 'float';
|
||||
break;
|
||||
case 'decimal':
|
||||
case 'money':
|
||||
case 'numeric':
|
||||
$type[] = 'decimal';
|
||||
break;
|
||||
case 'tinyblob':
|
||||
case 'mediumblob':
|
||||
case 'longblob':
|
||||
case 'blob':
|
||||
case 'bytea':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'oid':
|
||||
$type[] = 'blob';
|
||||
$type[] = 'clob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'year':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
default:
|
||||
throw DoctrineException::updateMe('unknown database attribute type: '.$dbType);
|
||||
}
|
||||
|
||||
return array('type' => $type,
|
||||
'length' => $length,
|
||||
'unsigned' => $unsigned,
|
||||
'fixed' => $fixed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the md5 sum of a field.
|
||||
|
|
|
@ -166,27 +166,6 @@ class MySqlSchemaManager extends AbstractSchemaManager
|
|||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'enum':
|
||||
$type = 'enum';
|
||||
preg_match_all('/\'((?:\'\'|[^\'])*)\'/', $tableColumn['type'], $matches);
|
||||
$length = 0;
|
||||
$fixed = false;
|
||||
if (is_array($matches)) {
|
||||
foreach ($matches[1] as &$value) {
|
||||
$value = str_replace('\'\'', '\'', $value);
|
||||
$length = max($length, strlen($value));
|
||||
}
|
||||
if ($length == '1' && count($matches[1]) == 2) {
|
||||
$type = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $tableColumn['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
|
||||
$values = $matches[1];
|
||||
}
|
||||
$type = 'integer';
|
||||
break;
|
||||
case 'set':
|
||||
$fixed = false;
|
||||
$type = 'text';
|
||||
|
|
|
@ -61,11 +61,6 @@ abstract class AbstractQuery
|
|||
*/
|
||||
protected $_params = array();
|
||||
|
||||
/**
|
||||
* @var array $_enumParams Array containing the keys of the parameters that should be enumerated.
|
||||
*/
|
||||
//protected $_enumParams = array();
|
||||
|
||||
/**
|
||||
* The user-specified ResultSetMapping to use.
|
||||
*
|
||||
|
@ -133,46 +128,8 @@ abstract class AbstractQuery
|
|||
public function free()
|
||||
{
|
||||
$this->_params = array();
|
||||
$this->_enumParams = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enumerated parameters
|
||||
*
|
||||
* @param array $enumParams Enum parameters.
|
||||
*/
|
||||
/*protected function _setEnumParams($enumParams = array())
|
||||
{
|
||||
$this->_enumParams = $enumParams;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get all enumerated parameters
|
||||
*
|
||||
* @return array All enumerated parameters
|
||||
*/
|
||||
/*public function getEnumParams()
|
||||
{
|
||||
return $this->_enumParams;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Convert ENUM parameters to their integer equivalents
|
||||
*
|
||||
* @param $params Parameters to be converted
|
||||
* @return array Converted parameters array
|
||||
*/
|
||||
/*public function convertEnums($params)
|
||||
{
|
||||
foreach ($this->_enumParams as $key => $values) {
|
||||
if (isset($params[$key]) && ! empty($values)) {
|
||||
$params[$key] = $values[0]->enumIndex($values[1], $params[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get all defined parameters
|
||||
*
|
||||
|
|
|
@ -41,21 +41,6 @@ abstract class AbstractResult
|
|||
*/
|
||||
protected $_data;
|
||||
|
||||
/**
|
||||
* @var array Enum params.
|
||||
*/
|
||||
//protected $_enumParams = array();
|
||||
|
||||
/**
|
||||
* Returns the enum parameters.
|
||||
*
|
||||
* @return mixed Enum parameters.
|
||||
*/
|
||||
/*public function getEnumParams()
|
||||
{
|
||||
return $this->_enumParams;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns this object in serialized format, revertable using fromCached*.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue