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
d3098e3a
Commit
d3098e3a
authored
Jun 19, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor validator fix
parent
7b19bef1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
26 deletions
+51
-26
Collection.php
Doctrine/Collection.php
+4
-2
Form.php
Doctrine/Form.php
+8
-9
Lib.php
Doctrine/Lib.php
+5
-5
Record.php
Doctrine/Record.php
+7
-4
Table.php
Doctrine/Table.php
+11
-4
Validator.php
Doctrine/Validator.php
+15
-2
ValidatorTestCase.php
tests/ValidatorTestCase.php
+1
-0
No files found.
Doctrine/Collection.php
View file @
d3098e3a
...
...
@@ -312,8 +312,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @return boolean
*/
public
function
remove
(
$key
)
{
if
(
!
isset
(
$this
->
data
[
$key
]))
if
(
!
isset
(
$this
->
data
[
$key
]))
{
$this
->
expand
(
$key
);
throw
new
InvalidKeyException
();
}
$removed
=
$this
->
data
[
$key
];
...
...
@@ -417,7 +419,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
in_array
(
$record
,
$this
->
data
))
{
return
false
;
}
else
}
if
(
isset
(
$this
->
generator
))
{
$key
=
$this
->
generator
->
getIndex
(
$record
);
...
...
Doctrine/Form.php
View file @
d3098e3a
...
...
@@ -21,25 +21,24 @@ class Doctrine_Form implements Iterator {
$definitions
=
$this
->
columns
[
$column
];
$e
=
explode
(
"|"
,
$definitions
[
2
]);
$enum
=
false
;
foreach
(
$e
as
$v
)
{
$e2
=
explode
(
":"
,
$v
);
if
(
$e2
[
0
]
==
"enum"
)
{
$enum
=
explode
(
"-"
,
$e2
[
1
]);
break
;
}
}
if
(
$definitions
[
0
]
==
"enum"
)
$enum
=
$this
->
record
->
getTable
()
->
getEnumValues
(
$column
);
$length
=
$definitions
[
1
];
if
(
!
in_array
(
"autoincrement"
,
$e
)
&&
!
in_array
(
"protected"
,
$e
))
{
if
(
$enum
)
{
$elements
[
$column
]
=
"<select name='data[
$column
]'>
\n
"
;
foreach
(
$enum
as
$k
=>
$v
)
{
if
(
$this
->
record
->
get
(
$column
)
==
$
k
)
{
if
(
$this
->
record
->
get
(
$column
)
==
$
v
)
{
$str
=
'selected'
;
}
else
$str
=
''
;
$elements
[
$column
]
.=
" <option value='
$
k
'
$str
>
$v
</option>
\n
"
;
$elements
[
$column
]
.=
" <option value='
$
v
'
$str
>
$v
</option>
\n
"
;
}
$elements
[
$column
]
.=
"</select>
\n
"
;
}
else
{
...
...
Doctrine/Lib.php
View file @
d3098e3a
...
...
@@ -29,7 +29,7 @@ class Doctrine_Lib {
* @param Doctrine_Record $record
* @return string
*/
public
function
getRecordAsString
(
Doctrine_Record
$record
)
{
public
static
function
getRecordAsString
(
Doctrine_Record
$record
)
{
$r
[]
=
"<pre>"
;
$r
[]
=
"Component : "
.
$record
->
getTable
()
->
getComponentName
();
$r
[]
=
"ID : "
.
$record
->
getID
();
...
...
@@ -65,7 +65,7 @@ class Doctrine_Lib {
* @param Doctrine_Session $session
* @return string
*/
public
function
getSessionAsString
(
Doctrine_Session
$session
)
{
public
static
function
getSessionAsString
(
Doctrine_Session
$session
)
{
$r
[]
=
"<pre>"
;
$r
[]
=
"Doctrine_Session object"
;
$r
[]
=
"State : "
.
Doctrine_Lib
::
getSessionStateAsString
(
$session
->
getState
());
...
...
@@ -109,7 +109,7 @@ class Doctrine_Lib {
* @param Doctrine_Table $table
* @return string
*/
public
function
getTableAsString
(
Doctrine_Table
$table
)
{
public
static
function
getTableAsString
(
Doctrine_Table
$table
)
{
$r
[]
=
"<pre>"
;
$r
[]
=
"Component : "
.
$this
->
getComponentName
();
$r
[]
=
"Table : "
.
$this
->
getTableName
();
...
...
@@ -124,7 +124,7 @@ class Doctrine_Lib {
/**
* @return string
*/
public
function
formatSql
(
$sql
)
{
public
static
function
formatSql
(
$sql
)
{
$e
=
explode
(
"
\n
"
,
$sql
);
$color
=
"367FAC"
;
$l
=
$sql
;
...
...
@@ -146,7 +146,7 @@ class Doctrine_Lib {
* @param Doctrine_Collection $collection
* @return string
*/
public
function
getCollectionAsString
(
Doctrine_Collection
$collection
)
{
public
static
function
getCollectionAsString
(
Doctrine_Collection
$collection
)
{
$r
[]
=
"<pre>"
;
$r
[]
=
get_class
(
$collection
);
...
...
Doctrine/Record.php
View file @
d3098e3a
...
...
@@ -172,6 +172,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// listen the onLoad event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
}
$this
->
table
->
getRepository
()
->
add
(
$this
);
}
}
...
...
@@ -229,7 +230,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
!
isset
(
$tmp
[
$name
]))
{
if
(
$type
==
'array'
)
{
$this
->
data
[
$name
]
=
array
();
$this
->
modified
[]
=
$name
;
}
else
$this
->
data
[
$name
]
=
self
::
$null
;
}
else
{
...
...
@@ -715,7 +715,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final
public
function
getModified
()
{
$a
=
array
();
foreach
(
$this
->
modified
as
$k
=>
$v
)
{
foreach
(
$this
->
modified
as
$k
=>
$v
)
{
$a
[
$v
]
=
$this
->
data
[
$v
];
}
return
$a
;
...
...
@@ -726,10 +726,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*
* @return array
*/
final
public
function
getPrepared
()
{
final
public
function
getPrepared
(
array
$array
=
array
()
)
{
$a
=
array
();
foreach
(
$this
->
modified
as
$k
=>
$v
)
{
if
(
empty
(
$array
))
$array
=
$this
->
modified
;
foreach
(
$array
as
$k
=>
$v
)
{
$type
=
$this
->
table
->
getTypeOf
(
$v
);
if
(
$type
==
'array'
||
...
...
Doctrine/Table.php
View file @
d3098e3a
...
...
@@ -127,13 +127,10 @@ class Doctrine_Table extends Doctrine_Configurable {
$record
=
new
$name
(
$this
);
$names
=
array
();
$class
=
$name
;
// get parent classes
do
{
...
...
@@ -825,6 +822,16 @@ class Doctrine_Table extends Doctrine_Configurable {
final
public
function
setEnumValues
(
$field
,
array
$values
)
{
$this
->
enum
[
$field
]
=
$values
;
}
/**
* @param string $field
* @return array
*/
final
public
function
getEnumValues
(
$field
)
{
if
(
isset
(
$this
->
enum
[
$field
]))
return
$this
->
enum
[
$field
];
else
return
array
();
}
/**
* enumValue
*/
...
...
@@ -836,7 +843,7 @@ class Doctrine_Table extends Doctrine_Configurable {
*/
final
public
function
enumIndex
(
$field
,
$value
)
{
$v
=
array_search
(
$value
,
$this
->
enum
[
$field
]);
return
(
$v
!==
false
)
?
$v
:
$value
;
return
$v
;
}
/**
* @return integer
...
...
Doctrine/Validator.php
View file @
d3098e3a
...
...
@@ -106,21 +106,31 @@ class Doctrine_Validator {
switch
(
$record
->
getState
())
:
case
Doctrine_Record
::
STATE_TDIRTY
:
case
Doctrine_Record
::
STATE_TCLEAN
:
// all fields will be validated
$data
=
$record
->
getData
();
break
;
default
:
// only the modified fields will be validated
$data
=
$record
->
getModified
();
endswitch
;
$err
=
array
();
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$value
===
self
::
$null
)
$value
=
null
;
$column
=
$columns
[
$key
];
if
(
$column
[
0
]
==
'array'
||
$column
[
0
]
==
'object'
)
if
(
$column
[
0
]
==
"enum"
)
{
$value
=
$record
->
getTable
()
->
enumIndex
(
$value
);
if
(
$value
===
false
)
{
$err
[
$key
]
=
Doctrine_Validator
::
ERR_ENUM
;
continue
;
}
}
if
(
$column
[
0
]
==
"array"
||
$column
[
0
]
==
"object"
)
$length
=
strlen
(
serialize
(
$value
));
else
$length
=
strlen
(
$value
);
...
...
@@ -199,6 +209,9 @@ class Doctrine_Validator {
*/
public
static
function
isValidType
(
$var
,
$type
)
{
$looseType
=
self
::
gettype
(
$var
);
if
(
$type
==
'enum'
)
$type
=
'integer'
;
switch
(
$looseType
)
:
case
'float'
:
case
'double'
:
...
...
tests/ValidatorTestCase.php
View file @
d3098e3a
...
...
@@ -158,5 +158,6 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$a
[
"User"
][
0
][
"name"
],
Doctrine_Validator
::
ERR_LENGTH
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
}
}
?>
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