Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0fdb2290
Commit
0fdb2290
authored
Sep 02, 2007
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added support for Doctrine::ATTR_USE_NATIVE_ENUM (defaults to off, no BC break)
parent
63c8c87a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
76 deletions
+96
-76
Doctrine.php
lib/Doctrine.php
+8
-7
Configurable.php
lib/Doctrine/Configurable.php
+8
-7
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+11
-3
Table.php
lib/Doctrine/Table.php
+69
-59
No files found.
lib/Doctrine.php
View file @
0fdb2290
...
...
@@ -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 ! */
...
...
lib/Doctrine/Configurable.php
View file @
0fdb2290
...
...
@@ -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
:
...
...
lib/Doctrine/DataDict/Mysql.php
View file @
0fdb2290
...
...
@@ -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
)
{
...
...
lib/Doctrine/Table.php
View file @
0fdb2290
...
...
@@ -1122,10 +1122,17 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
enumValue
(
$field
,
$index
)
{
if
(
$index
instanceof
Doctrine_Null
)
if
(
$index
instanceof
Doctrine_Null
)
{
return
$index
;
}
if
(
!
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
)
&&
isset
(
$this
->
columns
[
$field
][
'values'
][
$index
])
)
{
return
$this
->
columns
[
$field
][
'values'
][
$index
];
}
return
isset
(
$this
->
columns
[
$field
][
'values'
][
$index
])
?
$this
->
columns
[
$field
][
'values'
][
$index
]
:
$index
;
return
$index
;
}
/**
* enumIndex
...
...
@@ -1138,10 +1145,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
$values
=
$this
->
getEnumValues
(
$field
);
return
array_search
(
$value
,
$values
);
$index
=
array_search
(
$value
,
$values
);
if
(
$index
===
false
||
!
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
))
{
return
$index
;
}
/**
* getColumnCount
return
(
$index
+
1
);
}
/* getColumnCount
*
* @return integer the number of columns in this table
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment