Commit 0fdb2290 authored by lsmith's avatar lsmith

- added support for Doctrine::ATTR_USE_NATIVE_ENUM (defaults to off, no BC break)

parent 63c8c87a
...@@ -73,7 +73,7 @@ final class Doctrine ...@@ -73,7 +73,7 @@ final class Doctrine
const ERR_LOADMODULE = -34; const ERR_LOADMODULE = -34;
const ERR_INSUFFICIENT_DATA = -35; const ERR_INSUFFICIENT_DATA = -35;
const ERR_CLASS_NAME = -36; const ERR_CLASS_NAME = -36;
/** /**
* PDO derived constants * PDO derived constants
*/ */
...@@ -119,13 +119,13 @@ final class Doctrine ...@@ -119,13 +119,13 @@ final class Doctrine
/** /**
* ATTRIBUTE CONSTANTS * ATTRIBUTE CONSTANTS
*/ */
/** /**
* PDO derived attributes * PDO derived attributes
*/ */
const ATTR_AUTOCOMMIT = 0; const ATTR_AUTOCOMMIT = 0;
const ATTR_PREFETCH = 1; const ATTR_PREFETCH = 1;
const ATTR_TIMEOUT = 2; const ATTR_TIMEOUT = 2;
const ATTR_ERRMODE = 3; const ATTR_ERRMODE = 3;
const ATTR_SERVER_VERSION = 4; const ATTR_SERVER_VERSION = 4;
const ATTR_CLIENT_VERSION = 5; const ATTR_CLIENT_VERSION = 5;
...@@ -156,7 +156,7 @@ final class Doctrine ...@@ -156,7 +156,7 @@ final class Doctrine
const ATTR_DBNAME_FORMAT = 117; const ATTR_DBNAME_FORMAT = 117;
const ATTR_TBLCLASS_FORMAT = 119; const ATTR_TBLCLASS_FORMAT = 119;
const ATTR_EXPORT = 140; const ATTR_EXPORT = 140;
const ATTR_DECIMAL_PLACES = 141; const ATTR_DECIMAL_PLACES = 141;
const ATTR_PORTABILITY = 106; const ATTR_PORTABILITY = 106;
const ATTR_VLD = 107; const ATTR_VLD = 107;
...@@ -169,6 +169,7 @@ final class Doctrine ...@@ -169,6 +169,7 @@ final class Doctrine
const ATTR_DEF_VARCHAR_LENGTH = 114; const ATTR_DEF_VARCHAR_LENGTH = 114;
const ATTR_DEF_TABLESPACE = 115; const ATTR_DEF_TABLESPACE = 115;
const ATTR_EMULATE_DATABASE = 116; const ATTR_EMULATE_DATABASE = 116;
const ATTR_USE_NATIVE_ENUM = 117;
const ATTR_DEFAULT_SEQUENCE = 133; const ATTR_DEFAULT_SEQUENCE = 133;
/** TODO: REMOVE THE FOLLOWING CONSTANTS AND UPDATE THE DOCS ! */ /** TODO: REMOVE THE FOLLOWING CONSTANTS AND UPDATE THE DOCS ! */
...@@ -322,7 +323,7 @@ final class Doctrine ...@@ -322,7 +323,7 @@ final class Doctrine
/** /**
* EXPORT CONSTANTS * EXPORT CONSTANTS
*/ */
/** /**
* turns of exporting * turns of exporting
*/ */
...@@ -462,7 +463,7 @@ final class Doctrine ...@@ -462,7 +463,7 @@ final class Doctrine
* @return boolean * @return boolean
*/ */
public static function autoload($classname) public static function autoload($classname)
{ {
if (class_exists($classname, false)) { if (class_exists($classname, false)) {
return false; return false;
} }
...@@ -540,7 +541,7 @@ final class Doctrine ...@@ -540,7 +541,7 @@ final class Doctrine
{ {
if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) { if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) {
return false; return false;
} }
return true; return true;
} }
......
...@@ -43,7 +43,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -43,7 +43,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
protected $parent; protected $parent;
/** /**
* @var array $_impl an array containing concrete implementations for class templates * @var array $_impl an array containing concrete implementations for class templates
* keys as template names and values as names of the concrete * keys as template names and values as names of the concrete
* implementation classes * implementation classes
*/ */
protected $_impl = array(); protected $_impl = array();
...@@ -70,7 +70,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -70,7 +70,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{ {
if (is_string($attribute)) { if (is_string($attribute)) {
$upper = strtoupper($attribute); $upper = strtoupper($attribute);
$const = 'Doctrine::ATTR_' . $attribute; $const = 'Doctrine::ATTR_' . $attribute;
if (defined($const)) { if (defined($const)) {
$this->_state = constant($const); $this->_state = constant($const);
...@@ -93,7 +93,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -93,7 +93,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
throw new Doctrine_Exception("ATTR_CREATE_TABLES has been deprecated. See exporting in the first chapter of the manual."); throw new Doctrine_Exception("ATTR_CREATE_TABLES has been deprecated. See exporting in the first chapter of the manual.");
break; break;
case Doctrine::ATTR_ACCESSORS: case Doctrine::ATTR_ACCESSORS:
throw new Doctrine_Exception("Get / Set filtering is deprecated (slowed down Doctrine too much)."); throw new Doctrine_Exception("Get / Set filtering is deprecated (slowed down Doctrine too much).");
break; break;
case Doctrine::ATTR_COLL_LIMIT: case Doctrine::ATTR_COLL_LIMIT:
if ($value < 1) { if ($value < 1) {
...@@ -125,6 +125,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -125,6 +125,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
case Doctrine::ATTR_ACCESSOR_PREFIX_GET: case Doctrine::ATTR_ACCESSOR_PREFIX_GET:
case Doctrine::ATTR_ACCESSOR_PREFIX_SET: case Doctrine::ATTR_ACCESSOR_PREFIX_SET:
case Doctrine::ATTR_EMULATE_DATABASE: case Doctrine::ATTR_EMULATE_DATABASE:
case Doctrine::ATTR_USE_NATIVE_ENUM:
case Doctrine::ATTR_DEFAULT_SEQUENCE: case Doctrine::ATTR_DEFAULT_SEQUENCE:
case Doctrine::ATTR_EXPORT: case Doctrine::ATTR_EXPORT:
case Doctrine::ATTR_DECIMAL_PLACES: case Doctrine::ATTR_DECIMAL_PLACES:
...@@ -169,7 +170,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -169,7 +170,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
public function setImpl($template, $class) public function setImpl($template, $class)
{ {
$this->_impl[$template] = $class; $this->_impl[$template] = $class;
return $this; return $this;
} }
/** /**
...@@ -198,7 +199,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -198,7 +199,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) { if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) {
throw new Doctrine_Exception('Cache driver not initialized.'); throw new Doctrine_Exception('Cache driver not initialized.');
} }
return $this->attributes[Doctrine::ATTR_CACHE]; return $this->attributes[Doctrine::ATTR_CACHE];
} }
/** /**
...@@ -219,7 +220,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -219,7 +220,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{ {
if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER]) || if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER]) ||
! ($this->attributes[Doctrine::ATTR_RECORD_LISTENER] instanceof Doctrine_Record_Listener_Chain)) { ! ($this->attributes[Doctrine::ATTR_RECORD_LISTENER] instanceof Doctrine_Record_Listener_Chain)) {
$this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener_Chain(); $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener_Chain();
} }
$this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name); $this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name);
...@@ -268,7 +269,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object ...@@ -268,7 +269,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{ {
if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) || if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) ||
! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) {
$this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain(); $this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain();
} }
$this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name); $this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name);
......
...@@ -134,9 +134,9 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -134,9 +134,9 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
*/ */
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
if ( ! isset($field['type'])) { if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.'); throw new Doctrine_DataDict_Exception('Missing column type.');
} }
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
...@@ -185,9 +185,17 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -185,9 +185,17 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
} }
} }
return 'LONGBLOB'; return 'LONGBLOB';
case 'enum':
if ($this->conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
$values = array();
foreach ($field['values'] as $value) {
$values[] = $this->conn->quote($value, 'varchar');
}
return 'ENUM('.implode(', ', $values).')';
}
// fall back to integer
case 'integer': case 'integer':
case 'int': case 'int':
case 'enum':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 1) { if ($length <= 1) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment