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
239995d3
Commit
239995d3
authored
Dec 29, 2006
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed switch statement formating according to ZF CS
parent
b4ac430d
Changes
42
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
1336 additions
and
1341 deletions
+1336
-1341
Collection.php
lib/Doctrine/Collection.php
+27
-27
Batch.php
lib/Doctrine/Collection/Batch.php
+7
-7
Configurable.php
lib/Doctrine/Configurable.php
+78
-78
Connection.php
lib/Doctrine/Connection.php
+33
-33
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+11
-11
Firebird.php
lib/Doctrine/DataDict/Firebird.php
+36
-36
Informix.php
lib/Doctrine/DataDict/Informix.php
+43
-43
Mssql.php
lib/Doctrine/DataDict/Mssql.php
+85
-85
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+107
-107
Oracle.php
lib/Doctrine/DataDict/Oracle.php
+90
-90
Pgsql.php
lib/Doctrine/DataDict/Pgsql.php
+142
-142
Sqlite.php
lib/Doctrine/DataDict/Sqlite.php
+143
-143
Db.php
lib/Doctrine/Db.php
+27
-27
Firebird.php
lib/Doctrine/Export/Firebird.php
+38
-38
Mssql.php
lib/Doctrine/Export/Mssql.php
+10
-10
Mysql.php
lib/Doctrine/Export/Mysql.php
+1
-1
Oracle.php
lib/Doctrine/Export/Oracle.php
+9
-9
Pgsql.php
lib/Doctrine/Export/Pgsql.php
+1
-1
Sqlite.php
lib/Doctrine/Export/Sqlite.php
+6
-6
Mssql.php
lib/Doctrine/Expression/Mssql.php
+5
-5
Mysql.php
lib/Doctrine/Expression/Mysql.php
+10
-10
Oracle.php
lib/Doctrine/Expression/Oracle.php
+5
-5
Pgsql.php
lib/Doctrine/Expression/Pgsql.php
+11
-11
Sqlite.php
lib/Doctrine/Expression/Sqlite.php
+7
-7
Hydrate.php
lib/Doctrine/Hydrate.php
+17
-17
Lib.php
lib/Doctrine/Lib.php
+24
-24
Manager.php
lib/Doctrine/Manager.php
+27
-27
From.php
lib/Doctrine/Query/From.php
+4
-4
Where.php
lib/Doctrine/Query/Where.php
+36
-36
RawSql.php
lib/Doctrine/RawSql.php
+30
-30
Record.php
lib/Doctrine/Record.php
+94
-96
Association.php
lib/Doctrine/Relation/Association.php
+15
-15
Self.php
lib/Doctrine/Relation/Association/Self.php
+19
-19
Table.php
lib/Doctrine/Table.php
+76
-76
Transaction.php
lib/Doctrine/Transaction.php
+8
-8
Firebird.php
lib/Doctrine/Transaction/Firebird.php
+5
-5
Mssql.php
lib/Doctrine/Transaction/Mssql.php
+1
-2
Mysql.php
lib/Doctrine/Transaction/Mysql.php
+1
-2
Oracle.php
lib/Doctrine/Transaction/Oracle.php
+10
-10
Pgsql.php
lib/Doctrine/Transaction/Pgsql.php
+1
-2
Sqlite.php
lib/Doctrine/Transaction/Sqlite.php
+2
-2
Validator.php
lib/Doctrine/Validator.php
+34
-34
No files found.
lib/Doctrine/Collection.php
View file @
239995d3
...
...
@@ -308,37 +308,37 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$offset
=
null
;
switch
(
get_class
(
$this
))
{
case
"Doctrine_Collection_Offset"
:
$limit
=
$this
->
getLimit
();
$offset
=
(
floor
(
$key
/
$limit
)
*
$limit
);
case
"Doctrine_Collection_Offset"
:
$limit
=
$this
->
getLimit
();
$offset
=
(
floor
(
$key
/
$limit
)
*
$limit
);
if
(
!
$this
->
expandable
&&
isset
(
$this
->
expanded
[
$offset
]))
{
return
false
;
}
$fields
=
implode
(
", "
,
$this
->
table
->
getColumnNames
());
break
;
default
:
if
(
!
$this
->
expandable
)
{
return
false
;
}
if
(
!
isset
(
$this
->
reference
))
{
return
false
;
}
$id
=
$this
->
reference
->
obtainIdentifier
();
if
(
empty
(
$id
))
{
return
false
;
}
switch
(
get_class
(
$this
))
{
case
"Doctrine_Collection_Immediate"
:
if
(
!
$this
->
expandable
&&
isset
(
$this
->
expanded
[
$offset
]))
{
return
false
;
}
$fields
=
implode
(
", "
,
$this
->
table
->
getColumnNames
());
break
;
default
:
$fields
=
implode
(
", "
,
$this
->
table
->
getPrimaryKeys
());
};
if
(
!
$this
->
expandable
)
{
return
false
;
}
if
(
!
isset
(
$this
->
reference
))
{
return
false
;
}
$id
=
$this
->
reference
->
obtainIdentifier
();
if
(
empty
(
$id
))
{
return
false
;
}
switch
(
get_class
(
$this
))
{
case
"Doctrine_Collection_Immediate"
:
$fields
=
implode
(
", "
,
$this
->
table
->
getColumnNames
());
break
;
default
:
$fields
=
implode
(
", "
,
$this
->
table
->
getPrimaryKeys
());
};
};
if
(
isset
(
$this
->
relation
))
{
...
...
lib/Doctrine/Collection/Batch.php
View file @
239995d3
...
...
@@ -155,13 +155,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection
{
if
(
isset
(
$this
->
data
[
$key
]))
{
switch
(
gettype
(
$this
->
data
[
$key
]))
{
case
"array"
:
// Doctrine_Record didn't exist in cache
$this
->
table
->
setData
(
$this
->
data
[
$key
]);
$this
->
data
[
$key
]
=
$this
->
table
->
getProxy
();
$this
->
data
[
$key
]
->
addCollection
(
$this
);
break
;
case
"array"
:
// Doctrine_Record didn't exist in cache
$this
->
table
->
setData
(
$this
->
data
[
$key
]);
$this
->
data
[
$key
]
=
$this
->
table
->
getProxy
();
$this
->
data
[
$key
]
->
addCollection
(
$this
);
break
;
};
}
else
{
$this
->
expand
(
$key
);
...
...
lib/Doctrine/Configurable.php
View file @
239995d3
...
...
@@ -64,88 +64,88 @@ abstract class Doctrine_Configurable
public
function
setAttribute
(
$attribute
,
$value
)
{
switch
(
$attribute
)
{
case
Doctrine
::
ATTR_BATCH_SIZE
:
if
(
$value
<
0
)
{
throw
new
Doctrine_Exception
(
"Batch size should be greater than or equal to zero"
);
}
break
;
case
Doctrine
::
ATTR_FETCHMODE
:
if
(
$value
<
0
)
{
throw
new
Doctrine_Exception
(
"Unknown fetchmode. See Doctrine::FETCH_* constants."
);
}
break
;
case
Doctrine
::
ATTR_LISTENER
:
$this
->
setEventListener
(
$value
);
break
;
case
Doctrine
::
ATTR_LOCKMODE
:
if
(
$this
instanceof
Doctrine_Connection
)
{
if
(
$this
->
transaction
->
getState
()
!=
Doctrine_Transaction
::
STATE_SLEEP
)
{
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
case
Doctrine
::
ATTR_BATCH_SIZE
:
if
(
$value
<
0
)
{
throw
new
Doctrine_Exception
(
"Batch size should be greater than or equal to zero"
);
}
}
elseif
(
$this
instanceof
Doctrine_Manager
)
{
foreach
(
$this
as
$connection
)
{
if
(
$connection
->
transaction
->
getState
()
!=
Doctrine_Transaction
::
STATE_SLEEP
)
{
break
;
case
Doctrine
::
ATTR_FETCHMODE
:
if
(
$value
<
0
)
{
throw
new
Doctrine_Exception
(
"Unknown fetchmode. See Doctrine::FETCH_* constants."
);
}
break
;
case
Doctrine
::
ATTR_LISTENER
:
$this
->
setEventListener
(
$value
);
break
;
case
Doctrine
::
ATTR_LOCKMODE
:
if
(
$this
instanceof
Doctrine_Connection
)
{
if
(
$this
->
transaction
->
getState
()
!=
Doctrine_Transaction
::
STATE_SLEEP
)
{
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
}
elseif
(
$this
instanceof
Doctrine_Manager
)
{
foreach
(
$this
as
$connection
)
{
if
(
$connection
->
transaction
->
getState
()
!=
Doctrine_Transaction
::
STATE_SLEEP
)
{
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
}
}
else
{
throw
new
Doctrine_Exception
(
"Lockmode attribute can only be set at the global or connection level."
);
}
}
else
{
throw
new
Doctrine_Exception
(
"Lockmode attribute can only be set at the global or connection level."
);
}
break
;
case
Doctrine
::
ATTR_CREATE_TABLES
:
$value
=
(
bool
)
$value
;
break
;
case
Doctrine
::
ATTR_ACCESSORS
:
$accessors
=
array
(
'none'
,
'get'
,
'set'
,
'both'
);
// if ( ! in_array($value,$accessors)) {
// throw new Doctrine_Exception();
// }
break
;
case
Doctrine
::
ATTR_COLL_LIMIT
:
if
(
$value
<
1
)
{
throw
new
Doctrine_Exception
(
"Collection limit should be a value greater than or equal to 1."
);
}
break
;
case
Doctrine
::
ATTR_COLL_KEY
:
if
(
!
(
$this
instanceof
Doctrine_Table
))
{
throw
new
Doctrine_Exception
(
"This attribute can only be set at table level."
);
}
if
(
!
$this
->
hasColumn
(
$value
))
{
throw
new
Doctrine_Exception
(
"Couldn't set collection key attribute. No such column '
$value
'"
);
}
break
;
case
Doctrine
::
ATTR_VLD
:
case
Doctrine
::
ATTR_AUTO_LENGTH_VLD
:
case
Doctrine
::
ATTR_AUTO_TYPE_VLD
:
case
Doctrine
::
ATTR_QUERY_LIMIT
:
case
Doctrine
::
ATTR_QUOTE_IDENTIFIER
:
case
Doctrine
::
ATTR_PORTABILITY
:
case
Doctrine
::
ATTR_DEFAULT_TABLE_TYPE
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_GET
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_SET
:
break
;
case
Doctrine
::
ATTR_SEQCOL_NAME
:
if
(
!
is_string
(
$value
))
{
throw
new
Doctrine_Exception
(
'Sequence column name attribute only accepts string values'
);
}
break
;
case
Doctrine
::
ATTR_FIELD_CASE
:
if
(
$value
!=
0
&&
$value
!=
CASE_LOWER
&&
$value
!=
CASE_UPPER
)
throw
new
Doctrine_Exception
(
'Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'
);
break
;
case
Doctrine
::
ATTR_SEQNAME_FORMAT
:
case
Doctrine
::
ATTR_IDXNAME_FORMAT
:
if
(
$this
instanceof
Doctrine_Table
)
{
throw
new
Doctrine_Exception
(
'Sequence / index name format attributes cannot be set'
.
'at table level (only at connection or global level).'
);
}
break
;
default
:
throw
new
Doctrine_Exception
(
"Unknown attribute."
);
break
;
case
Doctrine
::
ATTR_CREATE_TABLES
:
$value
=
(
bool
)
$value
;
break
;
case
Doctrine
::
ATTR_ACCESSORS
:
$accessors
=
array
(
'none'
,
'get'
,
'set'
,
'both'
);
// if ( ! in_array($value,$accessors)) {
// throw new Doctrine_Exception();
// }
break
;
case
Doctrine
::
ATTR_COLL_LIMIT
:
if
(
$value
<
1
)
{
throw
new
Doctrine_Exception
(
"Collection limit should be a value greater than or equal to 1."
);
}
break
;
case
Doctrine
::
ATTR_COLL_KEY
:
if
(
!
(
$this
instanceof
Doctrine_Table
))
{
throw
new
Doctrine_Exception
(
"This attribute can only be set at table level."
);
}
if
(
!
$this
->
hasColumn
(
$value
))
{
throw
new
Doctrine_Exception
(
"Couldn't set collection key attribute. No such column '
$value
'"
);
}
break
;
case
Doctrine
::
ATTR_VLD
:
case
Doctrine
::
ATTR_AUTO_LENGTH_VLD
:
case
Doctrine
::
ATTR_AUTO_TYPE_VLD
:
case
Doctrine
::
ATTR_QUERY_LIMIT
:
case
Doctrine
::
ATTR_QUOTE_IDENTIFIER
:
case
Doctrine
::
ATTR_PORTABILITY
:
case
Doctrine
::
ATTR_DEFAULT_TABLE_TYPE
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_GET
:
case
Doctrine
::
ATTR_ACCESSOR_PREFIX_SET
:
break
;
case
Doctrine
::
ATTR_SEQCOL_NAME
:
if
(
!
is_string
(
$value
))
{
throw
new
Doctrine_Exception
(
'Sequence column name attribute only accepts string values'
);
}
break
;
case
Doctrine
::
ATTR_FIELD_CASE
:
if
(
$value
!=
0
&&
$value
!=
CASE_LOWER
&&
$value
!=
CASE_UPPER
)
throw
new
Doctrine_Exception
(
'Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'
);
break
;
case
Doctrine
::
ATTR_SEQNAME_FORMAT
:
case
Doctrine
::
ATTR_IDXNAME_FORMAT
:
if
(
$this
instanceof
Doctrine_Table
)
{
throw
new
Doctrine_Exception
(
'Sequence / index name format attributes cannot be set'
.
'at table level (only at connection or global level).'
);
}
break
;
default
:
throw
new
Doctrine_Exception
(
"Unknown attribute."
);
};
$this
->
attributes
[
$attribute
]
=
$value
;
...
...
lib/Doctrine/Connection.php
View file @
239995d3
...
...
@@ -160,13 +160,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
if
(
$this
->
modules
[
$name
]
===
false
)
{
switch
(
$name
)
{
case
'unitOfWork'
:
$this
->
modules
[
$name
]
=
new
Doctrine_Connection_UnitOfWork
(
$this
);
break
;
default
:
$class
=
'Doctrine_'
.
ucwords
(
$name
)
.
'_'
.
$this
->
getName
();
$this
->
modules
[
$name
]
=
new
$class
(
$this
);
}
case
'unitOfWork'
:
$this
->
modules
[
$name
]
=
new
Doctrine_Connection_UnitOfWork
(
$this
);
break
;
default
:
$class
=
'Doctrine_'
.
ucwords
(
$name
)
.
'_'
.
$this
->
getName
();
$this
->
modules
[
$name
]
=
new
$class
(
$this
);
}
}
return
$this
->
modules
[
$name
];
...
...
@@ -291,21 +291,21 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$type
=
gettype
(
$input
);
}
switch
(
$type
)
{
case
'integer'
:
case
'enum'
:
case
'boolean'
:
return
$input
;
case
'array'
:
case
'object'
:
$input
=
serialize
(
$input
);
case
'string'
:
case
'char'
:
case
'varchar'
:
case
'text'
:
case
'gzip'
:
case
'blob'
:
case
'clob'
:
return
$this
->
dbh
->
quote
(
$input
);
case
'integer'
:
case
'enum'
:
case
'boolean'
:
return
$input
;
case
'array'
:
case
'object'
:
$input
=
serialize
(
$input
);
case
'string'
:
case
'char'
:
case
'varchar'
:
case
'text'
:
case
'gzip'
:
case
'blob'
:
case
'clob'
:
return
$this
->
dbh
->
quote
(
$input
);
}
}
/**
...
...
@@ -874,17 +874,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreSave
(
$record
);
switch
(
$record
->
getState
())
{
case
Doctrine_Record
::
STATE_TDIRTY
:
$this
->
unitOfWork
->
insert
(
$record
);
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
case
Doctrine_Record
::
STATE_PROXY
:
$this
->
unitOfWork
->
update
(
$record
);
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_TCLEAN
:
// do nothing
break
;
case
Doctrine_Record
::
STATE_TDIRTY
:
$this
->
unitOfWork
->
insert
(
$record
);
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
case
Doctrine_Record
::
STATE_PROXY
:
$this
->
unitOfWork
->
update
(
$record
);
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_TCLEAN
:
// do nothing
break
;
};
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSave
(
$record
);
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
239995d3
...
...
@@ -204,11 +204,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
{
foreach
(
$record
->
getTable
()
->
getRelations
()
as
$fk
)
{
switch
(
$fk
->
getType
())
{
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$obj
=
$record
->
get
(
$fk
->
getAlias
());
$obj
->
delete
();
break
;
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$obj
=
$record
->
get
(
$fk
->
getAlias
());
$obj
->
delete
();
break
;
};
}
}
...
...
@@ -263,12 +263,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
if
(
$value
instanceof
Doctrine_Record
)
{
switch
(
$value
->
getState
())
{
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$record
->
save
();
default
:
$array
[
$name
]
=
$value
->
getIncremented
();
$record
->
set
(
$name
,
$value
->
getIncremented
());
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$record
->
save
();
default
:
$array
[
$name
]
=
$value
->
getIncremented
();
$record
->
set
(
$name
,
$value
->
getIncremented
());
};
}
};
...
...
lib/Doctrine/DataDict/Firebird.php
View file @
239995d3
...
...
@@ -57,38 +57,38 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
public
function
getNativeDeclaration
(
$field
)
{
switch
(
$field
[
'type'
])
{
case
'varchar'
:
case
'string'
:
case
'array'
:
case
'object'
:
case
'char'
:
case
'text'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
16777215
;
// TODO: $db->options['default_text_field_length'];
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
'CHAR('
.
$length
.
')'
:
'VARCHAR('
.
$length
.
')'
;
case
'clob'
:
return
'BLOB SUB_TYPE 1'
;
case
'blob'
:
return
'BLOB SUB_TYPE 0'
;
case
'integer'
:
case
'enum'
:
return
'INT'
;
case
'boolean'
:
return
'SMALLINT'
;
case
'date'
:
return
'DATE'
;
case
'time'
:
return
'TIME'
;
case
'timestamp'
:
return
'TIMESTAMP'
;
case
'float'
:
return
'DOUBLE PRECISION'
;
case
'decimal'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
18
;
return
'DECIMAL('
.
$length
.
','
.
$db
->
options
[
'decimal_places'
]
.
')'
;
case
'varchar'
:
case
'string'
:
case
'array'
:
case
'object'
:
case
'char'
:
case
'text'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
16777215
;
// TODO: $db->options['default_text_field_length'];
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
'CHAR('
.
$length
.
')'
:
'VARCHAR('
.
$length
.
')'
;
case
'clob'
:
return
'BLOB SUB_TYPE 1'
;
case
'blob'
:
return
'BLOB SUB_TYPE 0'
;
case
'integer'
:
case
'enum'
:
return
'INT'
;
case
'boolean'
:
return
'SMALLINT'
;
case
'date'
:
return
'DATE'
;
case
'time'
:
return
'TIME'
;
case
'timestamp'
:
return
'TIMESTAMP'
;
case
'float'
:
return
'DOUBLE PRECISION'
;
case
'decimal'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
18
;
return
'DECIMAL('
.
$length
.
','
.
$db
->
options
[
'decimal_places'
]
.
')'
;
}
return
''
;
}
...
...
@@ -129,7 +129,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
$type
=
array_reverse
(
$type
);
}
}
break
;
break
;
case
'varchar'
:
$fixed
=
false
;
case
'char'
:
...
...
@@ -144,15 +144,15 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
break
;
case
'date'
:
$type
[]
=
'date'
;
$length
=
null
;
break
;
break
;
case
'timestamp'
:
$type
[]
=
'timestamp'
;
$length
=
null
;
break
;
break
;
case
'time'
:
$type
[]
=
'time'
;
$length
=
null
;
...
...
lib/Doctrine/DataDict/Informix.php
View file @
239995d3
...
...
@@ -57,50 +57,50 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict
public
function
getNativeDeclaration
(
$field
)
{
switch
(
$field
[
'type'
])
{
case
'char'
:
case
'varchar'
:
case
'array'
:
case
'object'
:
case
'string'
:
if
(
empty
(
$field
[
'length'
])
&&
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
conn
->
varchar_max_length
;
}
$length
=
(
!
empty
(
$field
[
'length'
]))
?
$field
[
'length'
]
:
false
;
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'NVARCHAR'
);
case
'clob'
:
return
'TEXT'
;
case
'blob'
:
return
'BLOB'
;
case
'integer'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
1
)
{
return
'SMALLINT'
;
}
elseif
(
$length
==
2
)
{
return
'SMALLINT'
;
}
elseif
(
$length
==
3
||
$length
==
4
)
{
return
'INTEGER'
;
}
elseif
(
$length
>
4
)
{
return
'DECIMAL(20)'
;
case
'char'
:
case
'varchar'
:
case
'array'
:
case
'object'
:
case
'string'
:
if
(
empty
(
$field
[
'length'
])
&&
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
conn
->
varchar_max_length
;
}
}
return
'INT'
;
case
'boolean'
:
return
'SMALLINT'
;
case
'date'
:
return
'DATE'
;
case
'time'
:
return
'DATETIME YEAR TO SECOND'
;
case
'timestamp'
:
return
'DATETIME'
;
case
'float'
:
return
'FLOAT'
;
case
'decimal'
:
return
'DECIMAL'
;
$length
=
(
!
empty
(
$field
[
'length'
]))
?
$field
[
'length'
]
:
false
;
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'NVARCHAR'
);
case
'clob'
:
return
'TEXT'
;
case
'blob'
:
return
'BLOB'
;
case
'integer'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
1
)
{
return
'SMALLINT'
;
}
elseif
(
$length
==
2
)
{
return
'SMALLINT'
;
}
elseif
(
$length
==
3
||
$length
==
4
)
{
return
'INTEGER'
;
}
elseif
(
$length
>
4
)
{
return
'DECIMAL(20)'
;
}
}
return
'INT'
;
case
'boolean'
:
return
'SMALLINT'
;
case
'date'
:
return
'DATE'
;
case
'time'
:
return
'DATETIME YEAR TO SECOND'
;
case
'timestamp'
:
return
'DATETIME'
;
case
'float'
:
return
'FLOAT'
;
case
'decimal'
:
return
'DECIMAL'
;
}
return
''
;
}
...
...
lib/Doctrine/DataDict/Mssql.php
View file @
239995d3
...
...
@@ -59,51 +59,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
public
function
getNativeDeclaration
(
$field
)
{
switch
(
$field
[
'type'
])
{
case
'array'
:
case
'object'
:
case
'text'
:
case
'char'
:
case
'varchar'
:
case
'string'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
false
;
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR('
.
$db
->
options
[
'default_text_field_length'
]
.
')'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
case
'clob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
8000
)
{
return
'VARCHAR('
.
$length
.
')'
;
}
}
return
'TEXT'
;
case
'blob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
8000
)
{
return
"VARBINARY(
$length
)"
;
case
'array'
:
case
'object'
:
case
'text'
:
case
'char'
:
case
'varchar'
:
case
'string'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
false
;
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR('
.
$db
->
options
[
'default_text_field_length'
]
.
')'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
case
'clob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
8000
)
{
return
'VARCHAR('
.
$length
.
')'
;
}
}
return
'TEXT'
;
case
'blob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
8000
)
{
return
"VARBINARY(
$length
)"
;
}
}
}
return
'IMAGE'
;
case
'integer'
:
case
'enum'
:
return
'INT'
;
case
'boolean'
:
return
'BIT'
;
case
'date'
:
return
'CHAR('
.
strlen
(
'YYYY-MM-DD'
)
.
')'
;
case
'time'
:
return
'CHAR('
.
strlen
(
'HH:MM:SS'
)
.
')'
;
case
'timestamp'
:
return
'CHAR('
.
strlen
(
'YYYY-MM-DD HH:MM:SS'
)
.
')'
;
case
'float'
:
return
'FLOAT'
;
case
'decimal'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
18
;
return
'DECIMAL('
.
$length
.
','
.
$db
->
options
[
'decimal_places'
]
.
')'
;
return
'IMAGE'
;
case
'integer'
:
case
'enum'
:
return
'INT'
;
case
'boolean'
:
return
'BIT'
;
case
'date'
:
return
'CHAR('
.
strlen
(
'YYYY-MM-DD'
)
.
')'
;
case
'time'
:
return
'CHAR('
.
strlen
(
'HH:MM:SS'
)
.
')'
;
case
'timestamp'
:
return
'CHAR('
.
strlen
(
'YYYY-MM-DD HH:MM:SS'
)
.
')'
;
case
'float'
:
return
'FLOAT'
;
case
'decimal'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
18
;
return
'DECIMAL('
.
$length
.
','
.
$db
->
options
[
'decimal_places'
]
.
')'
;
}
return
''
;
}
...
...
@@ -124,48 +124,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
// todo: unsigned handling seems to be missing
$unsigned
=
$fixed
=
null
;
switch
(
$db_type
)
{
case
'bit'
:
$type
[
0
]
=
'boolean'
;
break
;
case
'int'
:
$type
[
0
]
=
'integer'
;
break
;
case
'datetime'
:
$type
[
0
]
=
'timestamp'
;
break
;
case
'float'
:
case
'real'
:
case
'numeric'
:
$type
[
0
]
=
'float'
;
break
;
case
'decimal'
:
case
'money'
:
$type
[
0
]
=
'decimal'
;
break
;
case
'text'
:
case
'varchar'
:
$fixed
=
false
;
case
'char'
:
$type
[
0
]
=
'text'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^[is|has]/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
case
'bit'
:
$type
[
0
]
=
'boolean'
;
break
;
case
'int'
:
$type
[
0
]
=
'integer'
;
break
;
case
'datetime'
:
$type
[
0
]
=
'timestamp'
;
break
;
case
'float'
:
case
'real'
:
case
'numeric'
:
$type
[
0
]
=
'float'
;
break
;
case
'decimal'
:
case
'money'
:
$type
[
0
]
=
'decimal'
;
break
;
case
'text'
:
case
'varchar'
:
$fixed
=
false
;
case
'char'
:
$type
[
0
]
=
'text'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^[is|has]/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$db_type
,
'text'
))
{
$type
[]
=
'clob'
;
}
}
elseif
(
strstr
(
$db_type
,
'text'
))
{
$type
[]
=
'clob'
;
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'image'
:
case
'varbinary'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Mssql_Exception
(
'unknown database attribute type: '
.
$db_type
);
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'image'
:
case
'varbinary'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Mssql_Exception
(
'unknown database attribute type: '
.
$db_type
);
}
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
...
...
lib/Doctrine/DataDict/Mysql.php
View file @
239995d3
...
...
@@ -236,122 +236,122 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$type
=
array
();
$unsigned
=
$fixed
=
null
;
switch
(
$dbType
)
{
case
'tinyint'
:
$type
[]
=
'integer'
;
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
1
;
break
;
case
'smallint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
2
;
break
;
case
'mediumint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
3
;
break
;
case
'int'
:
case
'integer'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
4
;
break
;
case
'bigint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
8
;
break
;
case
'tinytext'
:
case
'mediumtext'
:
case
'longtext'
:
case
'text'
:
case
'text'
:
case
'varchar'
:
$fixed
=
false
;
case
'string'
:
case
'char'
:
$type
[]
=
'text'
;
if
(
$length
==
'1'
)
{
case
'tinyint'
:
$type
[]
=
'integer'
;
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$dbType
,
'text'
))
{
$type
[]
=
'clob'
;
if
(
$decimal
==
'binary'
)
{
$type
[]
=
'blob'
;
}
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'enum'
:
$type
[]
=
'text'
;
preg_match_all
(
'/\'.+\'/U'
,
$field
[
'type'
],
$matches
);
$length
=
0
;
$fixed
=
false
;
if
(
is_array
(
$matches
))
{
foreach
(
$matches
[
0
]
as
$value
)
{
$length
=
max
(
$length
,
strlen
(
$value
)
-
2
);
}
if
(
$length
==
'1'
&&
count
(
$matches
[
0
])
==
2
)
{
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
1
;
break
;
case
'smallint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
2
;
break
;
case
'mediumint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
3
;
break
;
case
'int'
:
case
'integer'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
4
;
break
;
case
'bigint'
:
$type
[]
=
'integer'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
$length
=
8
;
break
;
case
'tinytext'
:
case
'mediumtext'
:
case
'longtext'
:
case
'text'
:
case
'text'
:
case
'varchar'
:
$fixed
=
false
;
case
'string'
:
case
'char'
:
$type
[]
=
'text'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$dbType
,
'text'
))
{
$type
[]
=
'clob'
;
if
(
$decimal
==
'binary'
)
{
$type
[]
=
'blob'
;
}
}
}
$type
[]
=
'integer'
;
case
'set'
:
$fixed
=
false
;
$type
[]
=
'text'
;
$type
[]
=
'integer'
;
break
;
case
'date'
:
$type
[]
=
'date'
;
$length
=
null
;
break
;
case
'datetime'
:
case
'timestamp'
:
$type
[]
=
'timestamp'
;
$length
=
null
;
break
;
case
'time'
:
$type
[]
=
'time'
;
$length
=
null
;
break
;
case
'float'
:
case
'double'
:
case
'real'
:
$type
[]
=
'float'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
break
;
case
'unknown'
:
case
'decimal'
:
case
'numeric'
:
$type
[]
=
'decimal'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
break
;
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
case
'year'
:
$type
[]
=
'integer'
;
$type
[]
=
'date'
;
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Mysql_Exception
(
'unknown database attribute type: '
.
$dbType
);
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'enum'
:
$type
[]
=
'text'
;
preg_match_all
(
'/\'.+\'/U'
,
$field
[
'type'
],
$matches
);
$length
=
0
;
$fixed
=
false
;
if
(
is_array
(
$matches
))
{
foreach
(
$matches
[
0
]
as
$value
)
{
$length
=
max
(
$length
,
strlen
(
$value
)
-
2
);
}
if
(
$length
==
'1'
&&
count
(
$matches
[
0
])
==
2
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
}
$type
[]
=
'integer'
;
case
'set'
:
$fixed
=
false
;
$type
[]
=
'text'
;
$type
[]
=
'integer'
;
break
;
case
'date'
:
$type
[]
=
'date'
;
$length
=
null
;
break
;
case
'datetime'
:
case
'timestamp'
:
$type
[]
=
'timestamp'
;
$length
=
null
;
break
;
case
'time'
:
$type
[]
=
'time'
;
$length
=
null
;
break
;
case
'float'
:
case
'double'
:
case
'real'
:
$type
[]
=
'float'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
break
;
case
'unknown'
:
case
'decimal'
:
case
'numeric'
:
$type
[]
=
'decimal'
;
$unsigned
=
preg_match
(
'/ unsigned/i'
,
$field
[
'type'
]);
break
;
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
case
'year'
:
$type
[]
=
'integer'
;
$type
[]
=
'date'
;
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Mysql_Exception
(
'unknown database attribute type: '
.
$dbType
);
}
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
...
...
lib/Doctrine/DataDict/Oracle.php
View file @
239995d3
...
...
@@ -54,38 +54,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
public
function
getNativeDeclaration
(
array
$field
)
{
switch
(
$field
[
'type'
])
{
case
'string'
:
case
'array'
:
case
'object'
:
case
'gzip'
:
case
'char'
:
case
'varchar'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
16777215
;
// TODO: $db->options['default_text_field_length'];
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
'CHAR('
.
$length
.
')'
:
'VARCHAR2('
.
$length
.
')'
;
case
'clob'
:
return
'CLOB'
;
case
'blob'
:
return
'BLOB'
;
case
'integer'
:
case
'enum'
:
if
(
!
empty
(
$field
[
'length'
]))
{
return
'NUMBER('
.
$field
[
'length'
]
.
')'
;
}
return
'INT'
;
case
'boolean'
:
return
'NUMBER(1)'
;
case
'date'
:
case
'time'
:
case
'timestamp'
:
return
'DATE'
;
case
'float'
:
return
'NUMBER'
;
case
'decimal'
:
return
'NUMBER(*,'
.
$db
->
options
[
'decimal_places'
]
.
')'
;
case
'string'
:
case
'array'
:
case
'object'
:
case
'gzip'
:
case
'char'
:
case
'varchar'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
16777215
;
// TODO: $db->options['default_text_field_length'];
$fixed
=
((
isset
(
$field
[
'fixed'
])
&&
$field
[
'fixed'
])
||
$field
[
'type'
]
==
'char'
)
?
true
:
false
;
return
$fixed
?
'CHAR('
.
$length
.
')'
:
'VARCHAR2('
.
$length
.
')'
;
case
'clob'
:
return
'CLOB'
;
case
'blob'
:
return
'BLOB'
;
case
'integer'
:
case
'enum'
:
if
(
!
empty
(
$field
[
'length'
]))
{
return
'NUMBER('
.
$field
[
'length'
]
.
')'
;
}
return
'INT'
;
case
'boolean'
:
return
'NUMBER(1)'
;
case
'date'
:
case
'time'
:
case
'timestamp'
:
return
'DATE'
;
case
'float'
:
return
'NUMBER'
;
case
'decimal'
:
return
'NUMBER(*,'
.
$db
->
options
[
'decimal_places'
]
.
')'
;
}
}
/**
...
...
@@ -104,46 +104,9 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
$length
=
$field
[
'length'
];
}
switch
(
$db_type
)
{
case
'integer'
:
case
'pls_integer'
:
case
'binary_integer'
:
$type
[]
=
'integer'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
break
;
case
'varchar'
:
case
'varchar2'
:
case
'nvarchar2'
:
$fixed
=
false
;
case
'char'
:
case
'nchar'
:
$type
[]
=
'text'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'date'
:
case
'timestamp'
:
$type
[]
=
'timestamp'
;
$length
=
null
;
break
;
case
'float'
:
$type
[]
=
'float'
;
break
;
case
'number'
:
if
(
!
empty
(
$field
[
'scale'
]))
{
$type
[]
=
'decimal'
;
}
else
{
case
'integer'
:
case
'pls_integer'
:
case
'binary_integer'
:
$type
[]
=
'integer'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
...
...
@@ -151,25 +114,62 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
$type
=
array_reverse
(
$type
);
}
}
}
break
;
case
'long'
:
$type
[]
=
'text'
;
case
'clob'
:
case
'nclob'
:
$type
[]
=
'clob'
;
break
;
case
'varchar'
:
case
'varchar2'
:
case
'nvarchar2'
:
$fixed
=
false
;
case
'char'
:
case
'nchar'
:
$type
[]
=
'text'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'date'
:
case
'timestamp'
:
$type
[]
=
'timestamp'
;
$length
=
null
;
break
;
case
'float'
:
$type
[]
=
'float'
;
break
;
case
'number'
:
if
(
!
empty
(
$field
[
'scale'
]))
{
$type
[]
=
'decimal'
;
}
else
{
$type
[]
=
'integer'
;
if
(
$length
==
'1'
)
{
$type
[]
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
}
break
;
case
'long'
:
$type
[]
=
'text'
;
case
'clob'
:
case
'nclob'
:
$type
[]
=
'clob'
;
break
;
case
'blob'
:
case
'raw'
:
case
'long raw'
:
case
'bfile'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
case
'blob'
:
case
'raw'
:
case
'long raw'
:
case
'bfile'
:
$type
[]
=
'blob'
;
$length
=
null
;
break
;
case
'rowid'
:
case
'urowid'
:
default
:
throw
new
Doctrine_DataDict_Oracle_Exception
(
'unknown database attribute type: '
.
$db_type
);
case
'rowid'
:
case
'urowid'
:
default
:
throw
new
Doctrine_DataDict_Oracle_Exception
(
'unknown database attribute type: '
.
$db_type
);
}
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
...
...
lib/Doctrine/DataDict/Pgsql.php
View file @
239995d3
This diff is collapsed.
Click to expand it.
lib/Doctrine/DataDict/Sqlite.php
View file @
239995d3
This diff is collapsed.
Click to expand it.
lib/Doctrine/Db.php
View file @
239995d3
...
...
@@ -247,33 +247,33 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
throw
new
Doctrine_Db_Exception
(
'Driver '
.
$parts
[
'scheme'
]
.
' not availible or extension not loaded'
);
}
switch
(
$parts
[
'scheme'
])
{
case
'sqlite'
:
if
(
isset
(
$parts
[
'host'
])
&&
$parts
[
'host'
]
==
':memory'
)
{
$parts
[
'database'
]
=
':memory:'
;
$parts
[
'dsn'
]
=
'sqlite::memory:'
;
}
break
;
case
'mysql'
:
case
'informix'
:
case
'oci8'
:
case
'mssql'
:
case
'firebird'
:
case
'pgsql'
:
case
'odbc'
:
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
throw
new
Doctrine_Db_Exception
(
'No database availible in data source name'
);
}
if
(
isset
(
$parts
[
'path'
]))
{
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
}
if
(
!
isset
(
$parts
[
'host'
]))
{
throw
new
Doctrine_Db_Exception
(
'No hostname set in data source name'
);
}
$parts
[
'dsn'
]
=
$parts
[
"scheme"
]
.
":host="
.
$parts
[
"host"
]
.
";dbname="
.
$parts
[
"database"
];
break
;
default
:
throw
new
Doctrine_Db_Exception
(
'Unknown driver '
.
$parts
[
'scheme'
]);
case
'sqlite'
:
if
(
isset
(
$parts
[
'host'
])
&&
$parts
[
'host'
]
==
':memory'
)
{
$parts
[
'database'
]
=
':memory:'
;
$parts
[
'dsn'
]
=
'sqlite::memory:'
;
}
break
;
case
'mysql'
:
case
'informix'
:
case
'oci8'
:
case
'mssql'
:
case
'firebird'
:
case
'pgsql'
:
case
'odbc'
:
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
throw
new
Doctrine_Db_Exception
(
'No database availible in data source name'
);
}
if
(
isset
(
$parts
[
'path'
]))
{
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
}
if
(
!
isset
(
$parts
[
'host'
]))
{
throw
new
Doctrine_Db_Exception
(
'No hostname set in data source name'
);
}
$parts
[
'dsn'
]
=
$parts
[
"scheme"
]
.
":host="
.
$parts
[
"host"
]
.
";dbname="
.
$parts
[
"database"
];
break
;
default
:
throw
new
Doctrine_Db_Exception
(
'Unknown driver '
.
$parts
[
'scheme'
]);
}
return
$parts
;
...
...
lib/Doctrine/Export/Firebird.php
View file @
239995d3
...
...
@@ -189,25 +189,25 @@ class Doctrine_Export_Firebird extends Doctrine_Export
{
foreach
(
$changes
as
$change_name
=>
$change
)
{
switch
(
$change_name
)
{
case
'notnull'
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported changes to field not null constraint'
,
__FUNCTION__
);
case
'default'
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported changes to field default value'
,
__FUNCTION__
);
case
'length'
:
/*
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported changes to field default length', __FUNCTION__);
*/
case
'unsigned'
:
case
'type'
:
case
'declaration'
:
case
'definition'
:
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported change of type'
.
$change_name
,
__FUNCTION__
);
case
'notnull'
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported changes to field not null constraint'
,
__FUNCTION__
);
case
'default'
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported changes to field default value'
,
__FUNCTION__
);
case
'length'
:
/*
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported changes to field default length', __FUNCTION__);
*/
case
'unsigned'
:
case
'type'
:
case
'declaration'
:
case
'definition'
:
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'it is not supported change of type'
.
$change_name
,
__FUNCTION__
);
}
}
return
MDB2_OK
;
...
...
@@ -320,20 +320,20 @@ class Doctrine_Export_Firebird extends Doctrine_Export
{
foreach
(
$changes
as
$change_name
=>
$change
)
{
switch
(
$change_name
)
{
case
'add'
:
case
'remove'
:
case
'rename'
:
break
;
case
'change'
:
foreach
(
$changes
[
'change'
]
as
$field
)
{
if
(
PEAR
::
isError
(
$err
=
$this
->
checkSupportedChanges
(
$field
)))
{
return
$err
;
case
'add'
:
case
'remove'
:
case
'rename'
:
break
;
case
'change'
:
foreach
(
$changes
[
'change'
]
as
$field
)
{
if
(
PEAR
::
isError
(
$err
=
$this
->
checkSupportedChanges
(
$field
)))
{
return
$err
;
}
}
}
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_CANNOT_ALTER
,
null
,
null
,
'change type '
.
$change_name
.
' not yet supported'
,
__FUNCTION__
);
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_CANNOT_ALTER
,
null
,
null
,
'change type '
.
$change_name
.
' not yet supported'
,
__FUNCTION__
);
}
}
if
(
$check
)
{
...
...
@@ -432,12 +432,12 @@ class Doctrine_Export_Firebird extends Doctrine_Export
foreach
(
$definition
[
'fields'
]
as
$field
)
{
if
(
!
strcmp
(
$query_sort
,
''
)
&&
isset
(
$field
[
'sorting'
]))
{
switch
(
$field
[
'sorting'
])
{
case
'ascending'
:
$query_sort
=
' ASC'
;
break
;
case
'descending'
:
$query_sort
=
' DESC'
;
break
;
case
'ascending'
:
$query_sort
=
' ASC'
;
break
;
case
'descending'
:
$query_sort
=
' DESC'
;
break
;
}
}
}
...
...
lib/Doctrine/Export/Mssql.php
View file @
239995d3
...
...
@@ -154,16 +154,16 @@ class Doctrine_Export_Mssql extends Doctrine_Export
{
foreach
(
$changes
as
$change_name
=>
$change
)
{
switch
(
$change_name
)
{
case
'add'
:
break
;
case
'remove'
:
break
;
case
'name'
:
case
'rename'
:
case
'change'
:
default
:
return
$db
->
raiseError
(
Doctrine
::
ERR_CANNOT_ALTER
,
null
,
null
,
'alterTable: change type "'
.
$change_name
.
'" not yet supported'
);
case
'add'
:
break
;
case
'remove'
:
break
;
case
'name'
:
case
'rename'
:
case
'change'
:
default
:
return
$db
->
raiseError
(
Doctrine
::
ERR_CANNOT_ALTER
,
null
,
null
,
'alterTable: change type "'
.
$change_name
.
'" not yet supported'
);
}
}
...
...
lib/Doctrine/Export/Mysql.php
View file @
239995d3
...
...
@@ -236,7 +236,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
case
'change'
:
case
'rename'
:
case
'name'
:
break
;
break
;
default
:
throw
new
Doctrine_Export_Mysql_Exception
(
'change type "'
.
$changeName
.
'" not yet supported'
);
}
...
...
lib/Doctrine/Export/Oracle.php
View file @
239995d3
...
...
@@ -343,15 +343,15 @@ END;
foreach
(
$changes
as
$changeName
=>
$change
)
{
switch
(
$changeName
)
{
case
'add'
:
case
'remove'
:
case
'change'
:
case
'name'
:
case
'rename'
:
break
;
default
:
return
$this
->
conn
->
raiseError
(
MDB2_ERROR_CANNOT_ALTER
,
null
,
null
,
'change type "'
.
$changeName
.
'" not yet supported'
,
__FUNCTION__
);
case
'add'
:
case
'remove'
:
case
'change'
:
case
'name'
:
case
'rename'
:
break
;
default
:
return
$this
->
conn
->
raiseError
(
MDB2_ERROR_CANNOT_ALTER
,
null
,
null
,
'change type "'
.
$changeName
.
'" not yet supported'
,
__FUNCTION__
);
}
}
...
...
lib/Doctrine/Export/Pgsql.php
View file @
239995d3
...
...
@@ -155,7 +155,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
case
'change'
:
case
'name'
:
case
'rename'
:
break
;
break
;
default
:
throw
new
Doctrine_Export_Pgsql_Exception
(
'change type "'
.
$change_name
.
'\" not yet supported'
);
}
...
...
lib/Doctrine/Export/Sqlite.php
View file @
239995d3
...
...
@@ -75,12 +75,12 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$fieldString
=
$fieldName
;
if
(
isset
(
$field
[
'sorting'
]))
{
switch
(
$field
[
'sorting'
])
{
case
'ascending'
:
$fieldString
.=
' ASC'
;
break
;
case
'descending'
:
$fieldString
.=
' DESC'
;
break
;
case
'ascending'
:
$fieldString
.=
' ASC'
;
break
;
case
'descending'
:
$fieldString
.=
' DESC'
;
break
;
}
}
$fields
[]
=
$fieldString
;
...
...
lib/Doctrine/Expression/Mssql.php
View file @
239995d3
...
...
@@ -45,11 +45,11 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression
public
function
now
(
$type
=
'timestamp'
)
{
switch
(
$type
)
{
case
'time'
:
case
'date'
:
case
'timestamp'
:
default
:
return
'GETDATE()'
;
case
'time'
:
case
'date'
:
case
'timestamp'
:
default
:
return
'GETDATE()'
;
}
}
/**
...
...
lib/Doctrine/Expression/Mysql.php
View file @
239995d3
...
...
@@ -65,16 +65,16 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression
$field
=
is_null
(
$field
)
?
''
:
$field
.
' '
;
$operator
=
strtoupper
(
$operator
);
switch
(
$operator
)
{
// case insensitive
case
'ILIKE'
:
$match
=
$field
.
'LIKE '
;
break
;
// case sensitive
case
'LIKE'
:
$match
=
$field
.
'LIKE BINARY '
;
break
;
default
:
throw
new
Doctrine_Expression_Mysql_Exception
(
'not a supported operator type:'
.
$operator
);
// case insensitive
case
'ILIKE'
:
$match
=
$field
.
'LIKE '
;
break
;
// case sensitive
case
'LIKE'
:
$match
=
$field
.
'LIKE BINARY '
;
break
;
default
:
throw
new
Doctrine_Expression_Mysql_Exception
(
'not a supported operator type:'
.
$operator
);
}
}
$match
.=
"'"
;
...
...
lib/Doctrine/Expression/Oracle.php
View file @
239995d3
...
...
@@ -77,11 +77,11 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression
public
function
now
(
$type
=
'timestamp'
)
{
switch
(
$type
)
{
case
'date'
:
case
'time'
:
case
'timestamp'
:
default
:
return
'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'
;
case
'date'
:
case
'time'
:
case
'timestamp'
:
default
:
return
'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'
;
}
}
/**
...
...
lib/Doctrine/Expression/Pgsql.php
View file @
239995d3
...
...
@@ -142,17 +142,17 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression
$field
=
is_null
(
$field
)
?
''
:
$field
.
' '
;
$operator
=
strtoupper
(
$operator
);
switch
(
$operator
)
{
// case insensitive
case
'ILIKE'
:
$match
=
$field
.
'ILIKE '
;
break
;
// case sensitive
case
'LIKE'
:
$match
=
$field
.
'LIKE '
;
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'not a supported operator type:'
.
$operator
,
__FUNCTION__
);
// case insensitive
case
'ILIKE'
:
$match
=
$field
.
'ILIKE '
;
break
;
// case sensitive
case
'LIKE'
:
$match
=
$field
.
'LIKE '
;
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'not a supported operator type:'
.
$operator
,
__FUNCTION__
);
}
}
$match
.=
"'"
;
...
...
lib/Doctrine/Expression/Sqlite.php
View file @
239995d3
...
...
@@ -125,13 +125,13 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression
public
function
now
(
$type
=
'timestamp'
)
{
switch
(
$type
)
{
case
'time'
:
return
'time(\'now\')'
;
case
'date'
:
return
'date(\'now\')'
;
case
'timestamp'
:
default
:
return
'datetime(\'now\')'
;
case
'time'
:
return
'time(\'now\')'
;
case
'date'
:
return
'date(\'now\')'
;
case
'timestamp'
:
default
:
return
'datetime(\'now\')'
;
}
}
/**
...
...
lib/Doctrine/Hydrate.php
View file @
239995d3
...
...
@@ -323,23 +323,23 @@ abstract class Doctrine_Hydrate extends Doctrine_Access
return
new
Doctrine_Collection
(
$table
);
}
switch
(
$this
->
fetchModes
[
$name
])
{
case
Doctrine
::
FETCH_BATCH
:
$coll
=
new
Doctrine_Collection_Batch
(
$table
);
break
;
case
Doctrine
::
FETCH_LAZY
:
$coll
=
new
Doctrine_Collection_Lazy
(
$table
);
break
;
case
Doctrine
::
FETCH_OFFSET
:
$coll
=
new
Doctrine_Collection_Offset
(
$table
);
break
;
case
Doctrine
::
FETCH_IMMEDIATE
:
$coll
=
new
Doctrine_Collection_Immediate
(
$table
);
break
;
case
Doctrine
::
FETCH_LAZY_OFFSET
:
$coll
=
new
Doctrine_Collection_LazyOffset
(
$table
);
break
;
default
:
throw
new
Doctrine_Exception
(
"Unknown fetchmode"
);
case
Doctrine
::
FETCH_BATCH
:
$coll
=
new
Doctrine_Collection_Batch
(
$table
);
break
;
case
Doctrine
::
FETCH_LAZY
:
$coll
=
new
Doctrine_Collection_Lazy
(
$table
);
break
;
case
Doctrine
::
FETCH_OFFSET
:
$coll
=
new
Doctrine_Collection_Offset
(
$table
);
break
;
case
Doctrine
::
FETCH_IMMEDIATE
:
$coll
=
new
Doctrine_Collection_Immediate
(
$table
);
break
;
case
Doctrine
::
FETCH_LAZY_OFFSET
:
$coll
=
new
Doctrine_Collection_LazyOffset
(
$table
);
break
;
default
:
throw
new
Doctrine_Exception
(
"Unknown fetchmode"
);
};
return
$coll
;
...
...
lib/Doctrine/Lib.php
View file @
239995d3
...
...
@@ -39,21 +39,21 @@ class Doctrine_Lib
public
static
function
getRecordStateAsString
(
$state
)
{
switch
(
$state
)
{
case
Doctrine_Record
::
STATE_PROXY
:
return
"proxy"
;
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
return
"persistent clean"
;
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
return
"persistent dirty"
;
break
;
case
Doctrine_Record
::
STATE_TDIRTY
:
return
"transient dirty"
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
return
"transient clean"
;
break
;
case
Doctrine_Record
::
STATE_PROXY
:
return
"proxy"
;
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
return
"persistent clean"
;
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
return
"persistent dirty"
;
break
;
case
Doctrine_Record
::
STATE_TDIRTY
:
return
"transient dirty"
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
return
"transient clean"
;
break
;
};
}
/**
...
...
@@ -80,15 +80,15 @@ class Doctrine_Lib
public
static
function
getConnectionStateAsString
(
$state
)
{
switch
(
$state
)
{
case
Doctrine_Transaction
::
STATE_SLEEP
:
return
"open"
;
break
;
case
Doctrine_Transaction
::
STATE_BUSY
:
return
"busy"
;
break
;
case
Doctrine_Transaction
::
STATE_ACTIVE
:
return
"active"
;
break
;
case
Doctrine_Transaction
::
STATE_SLEEP
:
return
"open"
;
break
;
case
Doctrine_Transaction
::
STATE_BUSY
:
return
"busy"
;
break
;
case
Doctrine_Transaction
::
STATE_ACTIVE
:
return
"active"
;
break
;
};
}
/**
...
...
lib/Doctrine/Manager.php
View file @
239995d3
...
...
@@ -192,33 +192,33 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$this
->
index
++
;
}
switch
(
$adapter
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
))
{
case
'mysql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mysql
(
$this
,
$adapter
);
break
;
case
'sqlite'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Sqlite
(
$this
,
$adapter
);
break
;
case
'pgsql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Pgsql
(
$this
,
$adapter
);
break
;
case
'oci'
:
case
'oracle'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Oracle
(
$this
,
$adapter
);
break
;
case
'mssql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mssql
(
$this
,
$adapter
);
break
;
case
'firebird'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Firebird
(
$this
,
$adapter
);
break
;
case
'informix'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Informix
(
$this
,
$adapter
);
break
;
case
'mock'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mock
(
$this
,
$adapter
);
break
;
default
:
throw
new
Doctrine_Manager_Exception
(
'Unknown connection driver '
.
$adapter
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
));
case
'mysql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mysql
(
$this
,
$adapter
);
break
;
case
'sqlite'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Sqlite
(
$this
,
$adapter
);
break
;
case
'pgsql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Pgsql
(
$this
,
$adapter
);
break
;
case
'oci'
:
case
'oracle'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Oracle
(
$this
,
$adapter
);
break
;
case
'mssql'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mssql
(
$this
,
$adapter
);
break
;
case
'firebird'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Firebird
(
$this
,
$adapter
);
break
;
case
'informix'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Informix
(
$this
,
$adapter
);
break
;
case
'mock'
:
$this
->
connections
[
$name
]
=
new
Doctrine_Connection_Mock
(
$this
,
$adapter
);
break
;
default
:
throw
new
Doctrine_Manager_Exception
(
'Unknown connection driver '
.
$adapter
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
));
};
$this
->
currIndex
=
$name
;
...
...
lib/Doctrine/Query/From.php
View file @
239995d3
...
...
@@ -48,10 +48,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part
$operator
=
false
;
switch
(
trim
(
$parts
[
0
]))
{
case
'INNER'
:
$operator
=
':'
;
case
'LEFT'
:
array_shift
(
$parts
);
case
'INNER'
:
$operator
=
':'
;
case
'LEFT'
:
array_shift
(
$parts
);
}
$last
=
''
;
...
...
lib/Doctrine/Query/Where.php
View file @
239995d3
...
...
@@ -64,24 +64,24 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$stack
=
$this
->
query
->
getTableStack
();
switch
(
$func
)
{
case
'contains'
:
case
'regexp'
:
case
'like'
:
$operator
=
$this
->
getOperator
(
$func
);
if
(
empty
(
$relation
))
{
throw
new
Doctrine_Query_Exception
(
'DQL functions contains/regexp/like can only be used for fields of related components'
);
}
$where
=
array
();
foreach
(
$values
as
$value
)
{
$where
[]
=
$alias
.
'.'
.
$relation
->
getLocal
()
.
' IN (SELECT '
.
$relation
->
getForeign
()
.
' FROM '
.
$relation
->
getTable
()
->
getTableName
()
.
' WHERE '
.
$field
.
$operator
.
$value
.
')'
;
}
$where
=
implode
(
' AND '
,
$where
);
break
;
default
:
throw
new
Doctrine_Query_Exception
(
'Unknown DQL function: '
.
$func
);
case
'contains'
:
case
'regexp'
:
case
'like'
:
$operator
=
$this
->
getOperator
(
$func
);
if
(
empty
(
$relation
))
{
throw
new
Doctrine_Query_Exception
(
'DQL functions contains/regexp/like can only be used for fields of related components'
);
}
$where
=
array
();
foreach
(
$values
as
$value
)
{
$where
[]
=
$alias
.
'.'
.
$relation
->
getLocal
()
.
' IN (SELECT '
.
$relation
->
getForeign
()
.
' FROM '
.
$relation
->
getTable
()
->
getTableName
()
.
' WHERE '
.
$field
.
$operator
.
$value
.
')'
;
}
$where
=
implode
(
' AND '
,
$where
);
break
;
default
:
throw
new
Doctrine_Query_Exception
(
'Unknown DQL function: '
.
$func
);
}
}
else
{
$table
=
$this
->
query
->
load
(
$reference
,
false
);
...
...
@@ -124,15 +124,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
}
switch
(
$operator
)
{
case
'<'
:
case
'>'
:
case
'='
:
case
'!='
:
if
(
$enumIndex
!==
false
)
{
$value
=
$enumIndex
;
}
default
:
$where
=
$alias
.
'.'
.
$field
.
' '
.
$operator
.
' '
.
$value
;
case
'<'
:
case
'>'
:
case
'='
:
case
'!='
:
if
(
$enumIndex
!==
false
)
{
$value
=
$enumIndex
;
}
default
:
$where
=
$alias
.
'.'
.
$field
.
' '
.
$operator
.
' '
.
$value
;
}
}
}
...
...
@@ -202,15 +202,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
public
function
getOperator
(
$func
)
{
switch
(
$func
)
{
case
'contains'
:
$operator
=
' = '
;
break
;
case
'regexp'
:
$operator
=
$this
->
query
->
getConnection
()
->
getRegexpOperator
();
break
;
case
'like'
:
$operator
=
' LIKE '
;
break
;
case
'contains'
:
$operator
=
' = '
;
break
;
case
'regexp'
:
$operator
=
$this
->
query
->
getConnection
()
->
getRegexpOperator
();
break
;
case
'like'
:
$operator
=
' LIKE '
;
break
;
}
return
$operator
;
}
...
...
lib/Doctrine/RawSql.php
View file @
239995d3
...
...
@@ -87,37 +87,37 @@ class Doctrine_RawSql extends Doctrine_Hydrate
foreach
(
$e
as
$k
=>
$part
)
{
$low
=
strtolower
(
$part
);
switch
(
strtolower
(
$part
))
{
case
"select"
:
case
"from"
:
case
"where"
:
case
"limit"
:
case
"offset"
:
case
"having"
:
$p
=
$low
;
if
(
!
isset
(
$parts
[
$low
]))
{
$parts
[
$low
]
=
array
();
}
break
;
case
"order"
:
case
"group"
:
$i
=
(
$k
+
1
);
if
(
isset
(
$e
[
$i
])
&&
strtolower
(
$e
[
$i
])
===
"by"
)
{
case
"select"
:
case
"from"
:
case
"where"
:
case
"limit"
:
case
"offset"
:
case
"having"
:
$p
=
$low
;
$p
.=
"by"
;
$parts
[
$low
.
"by"
]
=
array
();
}
else
{
$parts
[
$p
][]
=
$part
;
}
break
;
case
"by"
:
continue
;
default
:
if
(
!
isset
(
$parts
[
$p
][
0
]))
{
$parts
[
$p
][
0
]
=
$part
;
}
else
{
$parts
[
$p
][
0
]
.=
' '
.
$part
;
}
if
(
!
isset
(
$parts
[
$low
]))
{
$parts
[
$low
]
=
array
();
}
break
;
case
"order"
:
case
"group"
:
$i
=
(
$k
+
1
);
if
(
isset
(
$e
[
$i
])
&&
strtolower
(
$e
[
$i
])
===
"by"
)
{
$p
=
$low
;
$p
.=
"by"
;
$parts
[
$low
.
"by"
]
=
array
();
}
else
{
$parts
[
$p
][]
=
$part
;
}
break
;
case
"by"
:
continue
;
default
:
if
(
!
isset
(
$parts
[
$p
][
0
]))
{
$parts
[
$p
][
0
]
=
$part
;
}
else
{
$parts
[
$p
][
0
]
.=
' '
.
$part
;
}
};
};
...
...
lib/Doctrine/Record.php
View file @
239995d3
...
...
@@ -373,37 +373,35 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_data
[
$name
]
=
self
::
$null
;
}
else
{
switch
(
$type
)
{
case
"array"
:
case
"object"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
if
(
is_string
(
$tmp
[
$name
]))
{
$value
=
unserialize
(
$tmp
[
$name
]);
case
"array"
:
case
"object"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
if
(
is_string
(
$tmp
[
$name
]))
{
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Unserialization of
$name
failed."
);
}
else
{
$value
=
$tmp
[
$name
];
}
$this
->
_data
[
$name
]
=
$value
;
}
break
;
case
"gzip"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
$value
=
gzuncompress
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Un
serialization
of
$name
failed."
);
}
else
{
$
value
=
$tmp
[
$name
]
;
throw
new
Doctrine_Record_Exception
(
"Un
compressing
of
$name
failed."
);
$
this
->
_data
[
$name
]
=
$value
;
}
$this
->
_data
[
$name
]
=
$value
;
}
break
;
case
"gzip"
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
$value
=
gzuncompress
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Uncompressing of
$name
failed."
);
$this
->
_data
[
$name
]
=
$value
;
}
break
;
case
"enum"
:
$this
->
_data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
default
:
$this
->
_data
[
$name
]
=
$tmp
[
$name
];
break
;
case
"enum"
:
$this
->
_data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
default
:
$this
->
_data
[
$name
]
=
$tmp
[
$name
];
};
$count
++
;
}
...
...
@@ -421,38 +419,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
private
function
prepareIdentifiers
(
$exists
=
true
)
{
switch
(
$this
->
_table
->
getIdentifierType
())
{
case
Doctrine_Identifier
::
AUTO_INCREMENT
:
case
Doctrine_Identifier
::
SEQUENCE
:
$name
=
$this
->
_table
->
getIdentifier
();
if
(
$exists
)
{
case
Doctrine_Identifier
::
AUTO_INCREMENT
:
case
Doctrine_Identifier
::
SEQUENCE
:
$name
=
$this
->
_table
->
getIdentifier
();
if
(
$exists
)
{
if
(
isset
(
$this
->
_data
[
$name
])
&&
$this
->
_data
[
$name
]
!==
self
::
$null
)
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
}
}
unset
(
$this
->
_data
[
$name
]);
break
;
case
Doctrine_Identifier
::
NORMAL
:
$this
->
_id
=
array
();
$name
=
$this
->
_table
->
getIdentifier
();
if
(
isset
(
$this
->
_data
[
$name
])
&&
$this
->
_data
[
$name
]
!==
self
::
$null
)
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
}
}
unset
(
$this
->
_data
[
$name
]);
break
;
case
Doctrine_Identifier
::
NORMAL
:
$this
->
_id
=
array
();
$name
=
$this
->
_table
->
getIdentifier
();
if
(
isset
(
$this
->
_data
[
$name
])
&&
$this
->
_data
[
$name
]
!==
self
::
$null
)
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
}
break
;
case
Doctrine_Identifier
::
COMPOSITE
:
$names
=
$this
->
_table
->
getIdentifier
();
foreach
(
$names
as
$name
)
{
if
(
$this
->
_data
[
$name
]
===
self
::
$null
)
{
$this
->
_id
[
$name
]
=
null
;
}
else
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
break
;
case
Doctrine_Identifier
::
COMPOSITE
:
$names
=
$this
->
_table
->
getIdentifier
();
foreach
(
$names
as
$name
)
{
if
(
$this
->
_data
[
$name
]
===
self
::
$null
)
{
$this
->
_id
[
$name
]
=
null
;
}
else
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
}
}
}
break
;
break
;
};
}
/**
...
...
@@ -475,16 +473,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_data
=
array_merge
(
$this
->
_data
,
$this
->
_id
);
foreach
(
$this
->
_data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Record
)
if
(
$v
instanceof
Doctrine_Record
)
{
unset
(
$vars
[
'_data'
][
$k
]);
elseif
(
$v
===
self
::
$null
)
{
}
elseif
(
$v
===
self
::
$null
)
{
unset
(
$vars
[
'_data'
][
$k
]);
}
else
{
switch
(
$this
->
_table
->
getTypeOf
(
$k
))
{
case
"array"
:
case
"object"
:
$vars
[
'_data'
][
$k
]
=
serialize
(
$vars
[
'_data'
][
$k
]);
break
;
case
"array"
:
case
"object"
:
$vars
[
'_data'
][
$k
]
=
serialize
(
$vars
[
'_data'
][
$k
]);
break
;
};
}
}
...
...
@@ -560,16 +558,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
elseif
(
is_string
(
$state
))
{
$upper
=
strtoupper
(
$state
);
switch
(
$upper
)
{
case
'DIRTY'
:
case
'CLEAN'
:
case
'TDIRTY'
:
case
'TCLEAN'
:
case
'PROXY'
:
case
'DELETED'
:
$this
->
_state
=
constant
(
'Doctrine_Record::STATE_'
.
$upper
);
break
;
default
:
$err
=
true
;
case
'DIRTY'
:
case
'CLEAN'
:
case
'TDIRTY'
:
case
'TCLEAN'
:
case
'PROXY'
:
case
'DELETED'
:
$this
->
_state
=
constant
(
'Doctrine_Record::STATE_'
.
$upper
);
break
;
default
:
$err
=
true
;
}
}
...
...
@@ -819,12 +817,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_data
[
$lower
]
=
$value
;
$this
->
_modified
[]
=
$lower
;
switch
(
$this
->
_state
)
{
case
Doctrine_Record
::
STATE_CLEAN
:
$this
->
_state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
$this
->
_state
=
Doctrine_Record
::
STATE_TDIRTY
;
break
;
case
Doctrine_Record
::
STATE_CLEAN
:
$this
->
_state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
$this
->
_state
=
Doctrine_Record
::
STATE_TDIRTY
;
break
;
};
}
}
else
{
...
...
@@ -1007,24 +1005,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
switch
(
$type
)
{
case
'array'
:
case
'object'
:
$a
[
$v
]
=
serialize
(
$this
->
_data
[
$v
]);
break
;
case
'gzip'
:
$a
[
$v
]
=
gzcompress
(
$this
->
_data
[
$v
],
5
);
break
;
case
'boolean'
:
$a
[
$v
]
=
(
int
)
$this
->
_data
[
$v
];
break
;
case
'enum'
:
$a
[
$v
]
=
$this
->
_table
->
enumIndex
(
$v
,
$this
->
_data
[
$v
]);
case
'array'
:
case
'object'
:
$a
[
$v
]
=
serialize
(
$this
->
_data
[
$v
]);
break
;
case
'gzip'
:
$a
[
$v
]
=
gzcompress
(
$this
->
_data
[
$v
],
5
);
break
;
case
'boolean'
:
$a
[
$v
]
=
(
int
)
$this
->
_data
[
$v
];
break
;
default
:
if
(
$this
->
_data
[
$v
]
instanceof
Doctrine_Record
)
$this
->
_data
[
$v
]
=
$this
->
_data
[
$v
]
->
getIncremented
();
$a
[
$v
]
=
$this
->
_data
[
$v
];
case
'enum'
:
$a
[
$v
]
=
$this
->
_table
->
enumIndex
(
$v
,
$this
->
_data
[
$v
]);
break
;
default
:
if
(
$this
->
_data
[
$v
]
instanceof
Doctrine_Record
)
$this
->
_data
[
$v
]
=
$this
->
_data
[
$v
]
->
getIncremented
();
$a
[
$v
]
=
$this
->
_data
[
$v
];
}
}
...
...
lib/Doctrine/Relation/Association.php
View file @
239995d3
...
...
@@ -107,21 +107,21 @@ class Doctrine_Relation_Association extends Doctrine_Relation
public
function
getRelationDql
(
$count
,
$context
=
'record'
)
{
switch
(
$context
)
{
case
"record"
:
$sub
=
'SQL:SELECT '
.
$this
->
foreign
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
local
.
' IN ('
.
substr
(
str_repeat
(
"?, "
,
$count
),
0
,
-
2
)
.
')'
;
$dql
=
"FROM "
.
$this
->
table
->
getComponentName
();
$dql
.=
"."
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
" WHERE "
.
$this
->
table
->
getComponentName
()
.
"."
.
$this
->
table
->
getIdentifier
()
.
" IN (
$sub
)"
;
break
;
case
"collection"
:
$sub
=
substr
(
str_repeat
(
"?, "
,
$count
),
0
,
-
2
);
$dql
=
"FROM "
.
$this
->
associationTable
->
getComponentName
()
.
"."
.
$this
->
table
->
getComponentName
();
$dql
.=
" WHERE "
.
$this
->
associationTable
->
getComponentName
()
.
"."
.
$this
->
local
.
" IN (
$sub
)"
;
case
"record"
:
$sub
=
'SQL:SELECT '
.
$this
->
foreign
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
local
.
' IN ('
.
substr
(
str_repeat
(
"?, "
,
$count
),
0
,
-
2
)
.
')'
;
$dql
=
"FROM "
.
$this
->
table
->
getComponentName
();
$dql
.=
"."
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
" WHERE "
.
$this
->
table
->
getComponentName
()
.
"."
.
$this
->
table
->
getIdentifier
()
.
" IN (
$sub
)"
;
break
;
case
"collection"
:
$sub
=
substr
(
str_repeat
(
"?, "
,
$count
),
0
,
-
2
);
$dql
=
"FROM "
.
$this
->
associationTable
->
getComponentName
()
.
"."
.
$this
->
table
->
getComponentName
();
$dql
.=
" WHERE "
.
$this
->
associationTable
->
getComponentName
()
.
"."
.
$this
->
local
.
" IN (
$sub
)"
;
};
return
$dql
;
...
...
lib/Doctrine/Relation/Association/Self.php
View file @
239995d3
...
...
@@ -41,25 +41,25 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
public
function
getRelationDql
(
$count
,
$context
=
'record'
)
{
switch
(
$context
)
{
case
'record'
:
$sub
=
'SELECT '
.
$this
->
foreign
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
local
.
' = ?'
;
$sub2
=
'SELECT '
.
$this
->
local
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
foreign
.
' = ?'
;
$dql
=
'FROM '
.
$this
->
table
->
getComponentName
();
$dql
.=
'.'
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub
.
')'
;
$dql
.=
' || '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub2
.
')'
;
break
;
case
'collection'
:
$sub
=
substr
(
str_repeat
(
'?, '
,
$count
),
0
,
-
2
);
$dql
=
'FROM '
.
$this
->
associationTable
->
getComponentName
()
.
'.'
.
$this
->
table
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
associationTable
->
getComponentName
()
.
'.'
.
$this
->
local
.
' IN ('
.
$sub
.
')'
;
case
'record'
:
$sub
=
'SELECT '
.
$this
->
foreign
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
local
.
' = ?'
;
$sub2
=
'SELECT '
.
$this
->
local
.
' FROM '
.
$this
->
associationTable
->
getTableName
()
.
' WHERE '
.
$this
->
foreign
.
' = ?'
;
$dql
=
'FROM '
.
$this
->
table
->
getComponentName
();
$dql
.=
'.'
.
$this
->
associationTable
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub
.
')'
;
$dql
.=
' || '
.
$this
->
table
->
getComponentName
()
.
'.'
.
$this
->
table
->
getIdentifier
()
.
' IN ('
.
$sub2
.
')'
;
break
;
case
'collection'
:
$sub
=
substr
(
str_repeat
(
'?, '
,
$count
),
0
,
-
2
);
$dql
=
'FROM '
.
$this
->
associationTable
->
getComponentName
()
.
'.'
.
$this
->
table
->
getComponentName
();
$dql
.=
' WHERE '
.
$this
->
associationTable
->
getComponentName
()
.
'.'
.
$this
->
local
.
' IN ('
.
$sub
.
')'
;
};
return
$dql
;
...
...
lib/Doctrine/Table.php
View file @
239995d3
...
...
@@ -187,55 +187,55 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this
->
options
[
'tableName'
]
=
Doctrine
::
tableize
(
$class
->
getName
());
}
switch
(
count
(
$this
->
primaryKeys
))
{
case
0
:
$this
->
columns
=
array_merge
(
array
(
'id'
=>
array
(
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
)
)
),
$this
->
columns
);
$this
->
primaryKeys
[]
=
'id'
;
$this
->
identifier
=
'id'
;
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$this
->
columnCount
++
;
break
;
default
:
if
(
count
(
$this
->
primaryKeys
)
>
1
)
{
$this
->
identifier
=
$this
->
primaryKeys
;
$this
->
identifierType
=
Doctrine_Identifier
::
COMPOSITE
;
}
else
{
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$e
=
$this
->
columns
[
$pk
][
2
];
$found
=
false
;
foreach
(
$e
as
$option
=>
$value
)
{
if
(
$found
)
break
;
$e2
=
explode
(
":"
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
{
case
"autoincrement"
:
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$found
=
true
;
break
;
case
"seq"
:
$this
->
identifierType
=
Doctrine_Identifier
::
SEQUENCE
;
$found
=
true
;
break
;
};
}
if
(
!
isset
(
$this
->
identifierType
))
{
$this
->
identifierType
=
Doctrine_Identifier
::
NORMAL
;
case
0
:
$this
->
columns
=
array_merge
(
array
(
'id'
=>
array
(
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
)
)
),
$this
->
columns
);
$this
->
primaryKeys
[]
=
'id'
;
$this
->
identifier
=
'id'
;
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$this
->
columnCount
++
;
break
;
default
:
if
(
count
(
$this
->
primaryKeys
)
>
1
)
{
$this
->
identifier
=
$this
->
primaryKeys
;
$this
->
identifierType
=
Doctrine_Identifier
::
COMPOSITE
;
}
else
{
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$e
=
$this
->
columns
[
$pk
][
2
];
$found
=
false
;
foreach
(
$e
as
$option
=>
$value
)
{
if
(
$found
)
break
;
$e2
=
explode
(
":"
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
{
case
"autoincrement"
:
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$found
=
true
;
break
;
case
"seq"
:
$this
->
identifierType
=
Doctrine_Identifier
::
SEQUENCE
;
$found
=
true
;
break
;
};
}
if
(
!
isset
(
$this
->
identifierType
))
{
$this
->
identifierType
=
Doctrine_Identifier
::
NORMAL
;
}
$this
->
identifier
=
$pk
;
}
$this
->
identifier
=
$pk
;
}
}
};
if
(
$this
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
))
{
...
...
@@ -306,15 +306,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public
function
setOption
(
$name
,
$value
)
{
switch
(
$name
)
{
case
'name'
:
case
'tableName'
:
break
;
case
'enumMap'
:
case
'inheritanceMap'
:
if
(
!
is_array
(
$value
))
{
throw
new
Doctrine_Table_Exception
(
$name
.
' should be an array.'
);
}
break
;
case
'name'
:
case
'tableName'
:
break
;
case
'enumMap'
:
case
'inheritanceMap'
:
if
(
!
is_array
(
$value
))
{
throw
new
Doctrine_Table_Exception
(
$name
.
' should be an array.'
);
}
break
;
}
$this
->
options
[
$name
]
=
$value
;
}
...
...
@@ -422,12 +422,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
final
public
function
setPrimaryKey
(
$key
)
{
switch
(
gettype
(
$key
))
{
case
"array"
:
$this
->
primaryKeys
=
array_values
(
$key
);
break
;
case
"string"
:
$this
->
primaryKeys
[]
=
$key
;
break
;
case
"array"
:
$this
->
primaryKeys
=
array_values
(
$key
);
break
;
case
"string"
:
$this
->
primaryKeys
[]
=
$key
;
break
;
};
}
/**
...
...
@@ -491,20 +491,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$name
=
$this
->
getComponentName
();
foreach
(
$this
->
bound
as
$k
=>
$a
)
{
try
{
$fk
=
$this
->
getRelation
(
$k
);
switch
(
$fk
->
getType
())
{
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$n
=
$fk
->
getTable
()
->
getComponentName
();
$array
[]
=
$name
.
"."
.
$n
;
$e
=
$fk
->
getTable
()
->
getCompositePaths
();
if
(
!
empty
(
$e
))
{
foreach
(
$e
as
$name
)
{
$array
[]
=
$name
.
"."
.
$n
.
"."
.
$name
;
}
}
break
;
};
$fk
=
$this
->
getRelation
(
$k
);
switch
(
$fk
->
getType
())
{
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$n
=
$fk
->
getTable
()
->
getComponentName
();
$array
[]
=
$name
.
"."
.
$n
;
$e
=
$fk
->
getTable
()
->
getCompositePaths
();
if
(
!
empty
(
$e
))
{
foreach
(
$e
as
$name
)
{
$array
[]
=
$name
.
"."
.
$n
.
"."
.
$name
;
}
}
break
;
};
}
catch
(
Doctrine_Table_Exception
$e
)
{
}
...
...
lib/Doctrine/Transaction.php
View file @
239995d3
...
...
@@ -71,14 +71,14 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
public
function
getState
()
{
switch
(
$this
->
transactionLevel
)
{
case
0
:
return
Doctrine_Transaction
::
STATE_SLEEP
;
break
;
case
1
:
return
Doctrine_Transaction
::
STATE_ACTIVE
;
break
;
default
:
return
Doctrine_Transaction
::
STATE_BUSY
;
case
0
:
return
Doctrine_Transaction
::
STATE_SLEEP
;
break
;
case
1
:
return
Doctrine_Transaction
::
STATE_ACTIVE
;
break
;
default
:
return
Doctrine_Transaction
::
STATE_BUSY
;
}
}
/**
...
...
lib/Doctrine/Transaction/Firebird.php
View file @
239995d3
...
...
@@ -92,16 +92,16 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$nativeIsolation
=
'READ COMMITTED RECORD_VERSION'
;
break
;
break
;
case
'READ COMMITTED'
:
$nativeIsolation
=
'READ COMMITTED NO RECORD_VERSION'
;
break
;
break
;
case
'REPEATABLE READ'
:
$nativeIsolation
=
'SNAPSHOT'
;
break
;
break
;
case
'SERIALIZABLE'
:
$nativeIsolation
=
'SNAPSHOT TABLE STABILITY'
;
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'isolation level is not supported: '
.
$isolation
);
}
...
...
@@ -124,7 +124,7 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction
case
'READ ONLY'
:
case
'READ WRITE'
:
$rw
=
' '
.
$options
[
'rw'
];
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'wait option is not supported: '
.
$options
[
'rw'
]);
}
...
...
lib/Doctrine/Transaction/Mssql.php
View file @
239995d3
...
...
@@ -56,8 +56,7 @@ class Doctrine_Transaction_Mssql extends Doctrine_Transaction
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
case
'SNAPSHOT'
:
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'isolation level is not supported: '
.
$isolation
);
}
...
...
lib/Doctrine/Transaction/Mysql.php
View file @
239995d3
...
...
@@ -91,8 +91,7 @@ class Doctrine_Transaction_Mysql extends Doctrine_Transaction
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
}
...
...
lib/Doctrine/Transaction/Oracle.php
View file @
239995d3
...
...
@@ -85,16 +85,16 @@ class Doctrine_Transaction_Oracle extends Doctrine_Transaction
public
function
setIsolation
(
$isolation
)
{
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$isolation
=
'READ COMMITTED'
;
break
;
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
$isolation
=
'SERIALIZABLE'
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
case
'READ UNCOMMITTED'
:
$isolation
=
'READ COMMITTED'
;
break
;
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
$isolation
=
'SERIALIZABLE'
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
}
$query
=
'ALTER SESSION ISOLATION LEVEL '
.
$isolation
;
...
...
lib/Doctrine/Transaction/Pgsql.php
View file @
239995d3
...
...
@@ -91,8 +91,7 @@ class Doctrine_Transaction_Pgsql extends Doctrine_Transaction
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'Isolation level '
.
$isolation
.
' is not supported.'
);
}
...
...
lib/Doctrine/Transaction/Sqlite.php
View file @
239995d3
...
...
@@ -49,12 +49,12 @@ class Doctrine_Transaction_Sqlite extends Doctrine_Transaction
switch
(
$isolation
)
{
case
'READ UNCOMMITTED'
:
$isolation
=
0
;
break
;
break
;
case
'READ COMMITTED'
:
case
'REPEATABLE READ'
:
case
'SERIALIZABLE'
:
$isolation
=
1
;
break
;
break
;
default
:
throw
new
Doctrine_Transaction_Exception
(
'Isolation level '
.
$isolation
.
'is not supported.'
);
}
...
...
lib/Doctrine/Validator.php
View file @
239995d3
...
...
@@ -211,18 +211,18 @@ class Doctrine_Validator
public
static
function
phpType
(
$doctrineType
)
{
switch
(
$doctrineType
)
{
case
'enum'
:
return
'integer'
;
case
'blob'
:
case
'clob'
:
case
'mbstring'
:
case
'timestamp'
:
case
'date'
:
case
'gzip'
:
return
'string'
;
break
;
default
:
return
$doctrineType
;
case
'enum'
:
return
'integer'
;
case
'blob'
:
case
'clob'
:
case
'mbstring'
:
case
'timestamp'
:
case
'date'
:
case
'gzip'
:
return
'string'
;
break
;
default
:
return
$doctrineType
;
}
}
/**
...
...
@@ -242,19 +242,19 @@ class Doctrine_Validator
$type
=
self
::
phpType
(
$type
);
switch
(
$looseType
)
{
case
'float'
:
case
'double'
:
case
'integer'
:
if
(
$type
==
'string'
||
$type
==
'float'
)
case
'float'
:
case
'double'
:
case
'integer'
:
if
(
$type
==
'string'
||
$type
==
'float'
)
return
true
;
case
'string'
:
case
'array'
:
case
'object'
:
return
(
$type
===
$looseType
);
break
;
case
'NULL'
:
return
true
;
case
'string'
:
case
'array'
:
case
'object'
:
return
(
$type
===
$looseType
);
break
;
case
'NULL'
:
return
true
;
break
;
break
;
};
}
/**
...
...
@@ -267,17 +267,17 @@ class Doctrine_Validator
{
$type
=
gettype
(
$var
);
switch
(
$type
)
{
case
'string'
:
if
(
preg_match
(
"/^[0-9]+$/"
,
$var
))
{
return
'integer'
;
}
elseif
(
is_numeric
(
$var
))
{
return
'float'
;
}
else
{
case
'string'
:
if
(
preg_match
(
"/^[0-9]+$/"
,
$var
))
{
return
'integer'
;
}
elseif
(
is_numeric
(
$var
))
{
return
'float'
;
}
else
{
return
$type
;
}
break
;
default
:
return
$type
;
}
break
;
default
:
return
$type
;
};
}
}
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