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
const ERR_LOADMODULE = -34;
const ERR_INSUFFICIENT_DATA = -35;
const ERR_CLASS_NAME = -36;
/**
* PDO derived constants
*/
......@@ -119,13 +119,13 @@ final class Doctrine
/**
* ATTRIBUTE CONSTANTS
*/
/**
* PDO derived attributes
*/
const ATTR_AUTOCOMMIT = 0;
const ATTR_PREFETCH = 1;
const ATTR_TIMEOUT = 2;
const ATTR_TIMEOUT = 2;
const ATTR_ERRMODE = 3;
const ATTR_SERVER_VERSION = 4;
const ATTR_CLIENT_VERSION = 5;
......@@ -156,7 +156,7 @@ final class Doctrine
const ATTR_DBNAME_FORMAT = 117;
const ATTR_TBLCLASS_FORMAT = 119;
const ATTR_EXPORT = 140;
const ATTR_DECIMAL_PLACES = 141;
const ATTR_DECIMAL_PLACES = 141;
const ATTR_PORTABILITY = 106;
const ATTR_VLD = 107;
......@@ -169,6 +169,7 @@ final class Doctrine
const ATTR_DEF_VARCHAR_LENGTH = 114;
const ATTR_DEF_TABLESPACE = 115;
const ATTR_EMULATE_DATABASE = 116;
const ATTR_USE_NATIVE_ENUM = 117;
const ATTR_DEFAULT_SEQUENCE = 133;
/** TODO: REMOVE THE FOLLOWING CONSTANTS AND UPDATE THE DOCS ! */
......@@ -322,7 +323,7 @@ final class Doctrine
/**
* EXPORT CONSTANTS
*/
/**
* turns of exporting
*/
......@@ -462,7 +463,7 @@ final class Doctrine
* @return boolean
*/
public static function autoload($classname)
{
{
if (class_exists($classname, false)) {
return false;
}
......@@ -540,7 +541,7 @@ final class Doctrine
{
if (preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) {
return false;
}
}
return true;
}
......
......@@ -43,7 +43,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
protected $parent;
/**
* @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
*/
protected $_impl = array();
......@@ -70,7 +70,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{
if (is_string($attribute)) {
$upper = strtoupper($attribute);
$const = 'Doctrine::ATTR_' . $attribute;
if (defined($const)) {
$this->_state = constant($const);
......@@ -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.");
break;
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;
case Doctrine::ATTR_COLL_LIMIT:
if ($value < 1) {
......@@ -125,6 +125,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
case Doctrine::ATTR_ACCESSOR_PREFIX_GET:
case Doctrine::ATTR_ACCESSOR_PREFIX_SET:
case Doctrine::ATTR_EMULATE_DATABASE:
case Doctrine::ATTR_USE_NATIVE_ENUM:
case Doctrine::ATTR_DEFAULT_SEQUENCE:
case Doctrine::ATTR_EXPORT:
case Doctrine::ATTR_DECIMAL_PLACES:
......@@ -169,7 +170,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
public function setImpl($template, $class)
{
$this->_impl[$template] = $class;
return $this;
}
/**
......@@ -198,7 +199,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) {
throw new Doctrine_Exception('Cache driver not initialized.');
}
return $this->attributes[Doctrine::ATTR_CACHE];
}
/**
......@@ -219,7 +220,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{
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] = new Doctrine_Record_Listener_Chain();
}
$this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name);
......@@ -268,7 +269,7 @@ abstract class Doctrine_Configurable extends Doctrine_Object
{
if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) ||
! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) {
$this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain();
}
$this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name);
......
......@@ -134,9 +134,9 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
*/
public function getNativeDeclaration($field)
{
if ( ! isset($field['type'])) {
if ( ! isset($field['type'])) {
throw new Doctrine_DataDict_Exception('Missing column type.');
}
}
switch ($field['type']) {
case 'char':
......@@ -185,9 +185,17 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
}
}
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 'int':
case 'enum':
if (!empty($field['length'])) {
$length = $field['length'];
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