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
ddbf6c94
Commit
ddbf6c94
authored
Sep 17, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed default value support + camelCase column problems
parent
75284895
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
37 deletions
+48
-37
Pessimistic.php
Doctrine/Locking/Manager/Pessimistic.php
+2
-2
Record.php
Doctrine/Record.php
+26
-27
Table.php
Doctrine/Table.php
+16
-3
TableTestCase.php
tests/TableTestCase.php
+4
-5
No files found.
Doctrine/Locking/Manager/Pessimistic.php
View file @
ddbf6c94
...
...
@@ -57,8 +57,8 @@ class Doctrine_Locking_Manager_Pessimistic
if
(
$this
->
_dataSource
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
)
===
true
)
{
$columns
=
array
();
$columns
[
'object_type'
]
=
array
(
'string'
,
50
,
array
(
'notnull'
=>
true
,
'primary'
));
$columns
[
'object_key'
]
=
array
(
'string'
,
250
,
array
(
'notnull'
=>
true
,
'primary'
));
$columns
[
'object_type'
]
=
array
(
'string'
,
50
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
));
$columns
[
'object_key'
]
=
array
(
'string'
,
250
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
));
$columns
[
'user_ident'
]
=
array
(
'string'
,
50
,
array
(
'notnull'
=>
true
));
$columns
[
'timestamp_obtained'
]
=
array
(
'integer'
,
10
,
array
(
'notnull'
=>
true
));
...
...
Doctrine/Record.php
View file @
ddbf6c94
...
...
@@ -253,8 +253,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$default
===
null
)
$default
=
self
::
$null
;
if
(
$value
===
self
::
$null
||
$overwrite
)
if
(
$value
===
self
::
$null
||
$overwrite
)
{
$this
->
data
[
$column
]
=
$default
;
$this
->
modified
[]
=
$column
;
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
}
}
}
/**
...
...
@@ -281,35 +284,31 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
table
->
getTypeOf
(
$name
);
$lower
=
strtolower
(
$name
);
if
(
!
isset
(
$tmp
[
$lower
]))
{
//if($type == 'array') {
// $this->data[$name] = array();
//} else
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
switch
(
$type
)
:
case
"array"
:
case
"object"
:
if
(
$tmp
[
$
lower
]
!==
self
::
$null
)
{
if
(
is_string
(
$tmp
[
$
lower
]))
{
$value
=
unserialize
(
$tmp
[
$
lower
]);
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. "
.
var_dump
(
$tmp
[
$lower
],
true
));
}
else
$value
=
$tmp
[
$
lower
];
$value
=
$tmp
[
$
name
];
$this
->
data
[
$name
]
=
$value
;
}
break
;
case
"enum"
:
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$lower
]);
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
default
:
$this
->
data
[
$name
]
=
$tmp
[
$
lower
];
$this
->
data
[
$name
]
=
$tmp
[
$
name
];
endswitch
;
$count
++
;
}
...
...
@@ -601,36 +600,34 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
get
(
$name
,
$invoke
=
true
)
{
$listener
=
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
);
$value
=
self
::
$null
;
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
isset
(
$this
->
data
[
$lower
]))
{
// check if the property is null (= it is the Doctrine_Null object located in self::$null)
if
(
$this
->
data
[
$
name
]
===
self
::
$null
)
{
if
(
$this
->
data
[
$
lower
]
===
self
::
$null
)
{
$this
->
load
();
}
if
(
$this
->
data
[
$
name
]
===
self
::
$null
)
if
(
$this
->
data
[
$
lower
]
===
self
::
$null
)
$value
=
null
;
else
$value
=
$this
->
data
[
$
name
];
$value
=
$this
->
data
[
$
lower
];
}
if
(
$value
!==
self
::
$null
)
{
if
(
$invoke
&&
$name
!==
$this
->
table
->
getIdentifier
())
{
return
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onGetProperty
(
$this
,
$name
,
$value
);
}
else
return
$value
;
}
if
(
isset
(
$this
->
id
[
$
name
]))
return
$this
->
id
[
$
name
];
if
(
isset
(
$this
->
id
[
$
lower
]))
return
$this
->
id
[
$
lower
];
if
(
$name
===
$this
->
table
->
getIdentifier
())
return
null
;
...
...
@@ -706,7 +703,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
public
function
set
(
$name
,
$value
)
{
if
(
isset
(
$this
->
data
[
$name
]))
{
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
{
if
(
$value
instanceof
Doctrine_Record
)
{
$id
=
$value
->
getIncremented
();
...
...
@@ -715,7 +714,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
$id
;
}
$old
=
$this
->
get
(
$
name
,
false
);
$old
=
$this
->
get
(
$
lower
,
false
);
if
(
$old
!==
$value
)
{
...
...
@@ -725,8 +724,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$value
===
null
)
$value
=
self
::
$null
;
$this
->
data
[
$
name
]
=
$value
;
$this
->
modified
[]
=
$name
;
$this
->
data
[
$
lower
]
=
$value
;
$this
->
modified
[]
=
$lower
;
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_PROXY
:
...
...
Doctrine/Table.php
View file @
ddbf6c94
...
...
@@ -291,7 +291,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
unset
(
$options
[
$k
]);
}
}
$name
=
strtolower
(
$name
);
$this
->
columns
[
$name
]
=
array
(
$type
,
$length
,
$options
);
if
(
isset
(
$options
[
'primary'
]))
{
...
...
@@ -318,6 +318,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return mixed
*/
public
function
getDefaultValueOf
(
$column
)
{
$column
=
strtolower
(
$column
);
if
(
!
isset
(
$this
->
columns
[
$column
]))
throw
new
Doctrine_Table_Exception
(
"Couldn't get default value. Column "
.
$column
.
" doesn't exist."
);
...
...
@@ -680,7 +681,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this
->
relations
[
$alias
]
=
$relation
;
return
$this
->
relations
[
$alias
];
}
try
{
throw
new
Doctrine_Table_Exception
(
$this
->
name
.
" doesn't have a relation to "
.
$original
);
}
catch
(
Exception
$e
)
{
print
$e
;
}
}
/**
* returns an array containing all foreign key objects
...
...
@@ -922,7 +927,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return void
*/
final
public
function
setEnumValues
(
$field
,
array
$values
)
{
$this
->
enum
[
$field
]
=
$values
;
$this
->
enum
[
strtolower
(
$field
)
]
=
$values
;
}
/**
* @param string $field
...
...
@@ -936,12 +941,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
}
/**
* enumValue
*
* @param string $field
* @param integer $index
* @return mixed
*/
final
public
function
enumValue
(
$field
,
$index
)
{
return
isset
(
$this
->
enum
[
$field
][
$index
])
?
$this
->
enum
[
$field
][
$index
]
:
$index
;
}
/**
* enumIndex
*
* @param string $field
* @param mixed $value
* @return mixed
*/
final
public
function
enumIndex
(
$field
,
$value
)
{
if
(
!
isset
(
$this
->
enum
[
$field
]))
...
...
tests/TableTestCase.php
View file @
ddbf6c94
...
...
@@ -5,13 +5,10 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$this
->
tables
[]
=
"FieldNameTest"
;
parent
::
prepareTables
();
}
public
function
testFieldConversion
()
{
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_UPPER
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
5
);
$this
->
assertTrue
(
$user
instanceof
User
);
$t
=
new
FieldNameTest
();
$t
->
someColumn
=
'abc'
;
...
...
@@ -55,6 +52,7 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_NATURAL
);
}
public
function
testBind
()
{
$table
=
$this
->
connection
->
getTable
(
"User"
);
}
...
...
@@ -150,5 +148,6 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
public
function
testApplyInheritance
()
{
$this
->
assertEqual
(
$this
->
objTable
->
applyInheritance
(
"id = 3"
),
"id = 3 AND 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