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
da6f4a38
Commit
da6f4a38
authored
Oct 14, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #166
parent
2e8f73db
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
191 additions
and
187 deletions
+191
-187
Collection.php
lib/Doctrine/Collection.php
+1
-1
Hydrate.php
lib/Doctrine/Hydrate.php
+2
-2
Record.php
lib/Doctrine/Record.php
+181
-178
Advanced components - Validators - More Validation.php
...es/Advanced components - Validators - More Validation.php
+1
-1
classes.php
tests/classes.php
+3
-3
run.php
tests/run.php
+3
-2
No files found.
lib/Doctrine/Collection.php
View file @
da6f4a38
...
...
@@ -481,7 +481,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param Doctrine_Record $record
* @return void
*/
public
function
set
(
$key
,
Doctrine_Record
$record
)
{
public
function
set
(
$key
,
Doctrine_Record
$record
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
set
(
$this
->
reference_field
,
$this
->
reference
,
false
);
...
...
lib/Doctrine/Hydrate.php
View file @
da6f4a38
...
...
@@ -325,7 +325,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
return
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
if
(
count
(
$this
->
tables
)
==
0
)
throw
new
Doctrine_
Exception
(
"No table
s selected"
);
throw
new
Doctrine_
Query_Exception
(
"No component
s selected"
);
$keys
=
array_keys
(
$this
->
tables
);
$root
=
$keys
[
0
];
...
...
lib/Doctrine/Record.php
View file @
da6f4a38
...
...
@@ -65,27 +65,36 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* a Doctrine_Record turns into deleted state when it is deleted
*/
const
STATE_DELETED
=
6
;
/**
* the following protected variables use '_' prefixes, the reason for this is to allow child
* classes call for example $this->id, $this->state for getting the values of columns named 'id' and 'state'
* rather than the values of these protected variables
*/
/**
* @var object Doctrine_Table $table the factory that created this data access object
*/
protected
$table
;
protected
$
_
table
;
/**
* @var integer $id the primary keys of this object
*/
protected
$id
=
array
();
protected
$
_
id
=
array
();
/**
* @var array $data the record data
*/
protected
$data
=
array
();
protected
$
_
data
=
array
();
/**
* @var integer $state the state of this record
* @see STATE_* constants
*/
protected
$state
;
protected
$
_
state
;
/**
* @var array $modified an array containing properties that have been modified
*/
protected
$modified
=
array
();
protected
$_modified
=
array
();
/**
* @var Doctrine_Validator_ErrorStack error stack object
*/
protected
$_errorStack
;
/**
* @var array $collections the collections this record is in
*/
...
...
@@ -98,10 +107,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var array $originals an array containing all the original references
*/
private
$originals
=
array
();
/**
* @var Doctrine_Validator_ErrorStack error stack object
*/
protected
$errorStack
;
/**
* @var integer $index this index is used for creating object identifiers
*/
...
...
@@ -127,10 +132,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
__construct
(
$table
=
null
)
{
if
(
isset
(
$table
)
&&
$table
instanceof
Doctrine_Table
)
{
$this
->
table
=
$table
;
$exists
=
(
!
$this
->
table
->
isNewEntry
());
$this
->
_
table
=
$table
;
$exists
=
(
!
$this
->
_
table
->
isNewEntry
());
}
else
{
$this
->
table
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
()
->
getTable
(
get_class
(
$this
));
$this
->
_
table
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
()
->
getTable
(
get_class
(
$this
));
$exists
=
false
;
}
...
...
@@ -138,28 +143,28 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// If not this record is only used for creating table definition and setting up
// relations.
if
(
$this
->
table
->
getConnection
()
->
hasTable
(
$this
->
table
->
getComponentName
()))
{
if
(
$this
->
_table
->
getConnection
()
->
hasTable
(
$this
->
_
table
->
getComponentName
()))
{
$this
->
oid
=
self
::
$index
;
self
::
$index
++
;
$keys
=
$this
->
table
->
getPrimaryKeys
();
$keys
=
$this
->
_
table
->
getPrimaryKeys
();
if
(
!
$exists
)
{
// listen the onPreCreate event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreCreate
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreCreate
(
$this
);
}
else
{
// listen the onPreLoad event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreLoad
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreLoad
(
$this
);
}
// get the data array
$this
->
data
=
$this
->
table
->
getData
();
$this
->
_data
=
$this
->
_
table
->
getData
();
// get the column count
$count
=
count
(
$this
->
data
);
$count
=
count
(
$this
->
_
data
);
// clean data array
$this
->
cleanData
();
...
...
@@ -169,30 +174,30 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
!
$exists
)
{
if
(
$count
>
0
)
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
_
state
=
Doctrine_Record
::
STATE_TDIRTY
;
else
$this
->
state
=
Doctrine_Record
::
STATE_TCLEAN
;
$this
->
_
state
=
Doctrine_Record
::
STATE_TCLEAN
;
// set the default values for this record
$this
->
setDefaultValues
();
// listen the onCreate event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onCreate
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onCreate
(
$this
);
}
else
{
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
if
(
$count
<
$this
->
table
->
getColumnCount
())
{
$this
->
state
=
Doctrine_Record
::
STATE_PROXY
;
if
(
$count
<
$this
->
_
table
->
getColumnCount
())
{
$this
->
_
state
=
Doctrine_Record
::
STATE_PROXY
;
}
// listen the onLoad event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
}
$this
->
errorStack
=
new
Doctrine_Validator_ErrorStack
();
$this
->
_
errorStack
=
new
Doctrine_Validator_ErrorStack
();
$repository
=
$this
->
table
->
getRepository
();
$repository
=
$this
->
_
table
->
getRepository
();
$repository
->
add
(
$this
);
}
}
...
...
@@ -234,24 +239,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean whether or not this record passes all column validations
*/
public
function
isValid
()
{
if
(
!
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_VLD
))
if
(
!
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_VLD
))
return
true
;
// Clear the stack from any previous errors.
$this
->
errorStack
->
clear
();
$this
->
_
errorStack
->
clear
();
// Run validation process
$validator
=
new
Doctrine_Validator
();
$validator
->
validateRecord
(
$this
);
$this
->
validate
();
if
(
$this
->
state
==
self
::
STATE_TDIRTY
||
$this
->
state
==
self
::
STATE_TCLEAN
)
{
if
(
$this
->
_state
==
self
::
STATE_TDIRTY
||
$this
->
_
state
==
self
::
STATE_TCLEAN
)
{
$this
->
validateOnInsert
();
}
else
{
$this
->
validateOnUpdate
();
}
return
$this
->
errorStack
->
count
()
==
0
?
true
:
false
;
//$this->errorStack->merge($validator->getErrorStack());
return
$this
->
_errorStack
->
count
()
==
0
?
true
:
false
;
}
/**
* Emtpy template method to provide concrete Record classes with the possibility
...
...
@@ -277,7 +281,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return Doctrine_Validator_ErrorStack returns the errorStack associated with this record
*/
public
function
getErrorStack
()
{
return
$this
->
errorStack
;
return
$this
->
_
errorStack
;
}
/**
* setDefaultValues
...
...
@@ -287,19 +291,19 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean
*/
public
function
setDefaultValues
(
$overwrite
=
false
)
{
if
(
!
$this
->
table
->
hasDefaultValues
())
if
(
!
$this
->
_
table
->
hasDefaultValues
())
return
false
;
foreach
(
$this
->
data
as
$column
=>
$value
)
{
$default
=
$this
->
table
->
getDefaultValueOf
(
$column
);
foreach
(
$this
->
_
data
as
$column
=>
$value
)
{
$default
=
$this
->
_
table
->
getDefaultValueOf
(
$column
);
if
(
$default
===
null
)
$default
=
self
::
$null
;
if
(
$value
===
self
::
$null
||
$overwrite
)
{
$this
->
data
[
$column
]
=
$default
;
$this
->
modified
[]
=
$column
;
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
_
data
[
$column
]
=
$default
;
$this
->
_
modified
[]
=
$column
;
$this
->
_
state
=
Doctrine_Record
::
STATE_TDIRTY
;
}
}
}
...
...
@@ -328,17 +332,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer
*/
private
function
cleanData
(
$debug
=
false
)
{
$tmp
=
$this
->
data
;
$tmp
=
$this
->
_
data
;
$this
->
data
=
array
();
$this
->
_
data
=
array
();
$count
=
0
;
foreach
(
$this
->
table
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
table
->
getTypeOf
(
$name
);
foreach
(
$this
->
_
table
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
_
table
->
getTypeOf
(
$name
);
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
data
[
$name
]
=
self
::
$null
;
$this
->
_
data
[
$name
]
=
self
::
$null
;
}
else
{
switch
(
$type
)
:
case
"array"
:
...
...
@@ -353,7 +357,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
else
$value
=
$tmp
[
$name
];
$this
->
data
[
$name
]
=
$value
;
$this
->
_
data
[
$name
]
=
$value
;
}
break
;
case
"gzip"
:
...
...
@@ -365,14 +369,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Uncompressing of
$name
failed."
);
$this
->
data
[
$name
]
=
$value
;
$this
->
_
data
[
$name
]
=
$value
;
}
break
;
case
"enum"
:
$this
->
data
[
$name
]
=
$this
->
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
$this
->
_data
[
$name
]
=
$this
->
_
table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
default
:
$this
->
data
[
$name
]
=
$tmp
[
$name
];
$this
->
_
data
[
$name
]
=
$tmp
[
$name
];
endswitch
;
$count
++
;
}
...
...
@@ -389,35 +393,35 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
private
function
prepareIdentifiers
(
$exists
=
true
)
{
switch
(
$this
->
table
->
getIdentifierType
())
:
switch
(
$this
->
_
table
->
getIdentifierType
())
:
case
Doctrine_Identifier
::
AUTO_INCREMENT
:
case
Doctrine_Identifier
::
SEQUENCE
:
$name
=
$this
->
table
->
getIdentifier
();
$name
=
$this
->
_
table
->
getIdentifier
();
if
(
$exists
)
{
if
(
isset
(
$this
->
data
[
$name
])
&&
$this
->
data
[
$name
]
!==
self
::
$null
)
$this
->
id
[
$name
]
=
$this
->
data
[
$name
];
if
(
isset
(
$this
->
_data
[
$name
])
&&
$this
->
_
data
[
$name
]
!==
self
::
$null
)
$this
->
_id
[
$name
]
=
$this
->
_
data
[
$name
];
}
unset
(
$this
->
data
[
$name
]);
unset
(
$this
->
_
data
[
$name
]);
break
;
case
Doctrine_Identifier
::
NORMAL
:
$this
->
id
=
array
();
$name
=
$this
->
table
->
getIdentifier
();
$this
->
_
id
=
array
();
$name
=
$this
->
_
table
->
getIdentifier
();
if
(
isset
(
$this
->
data
[
$name
])
&&
$this
->
data
[
$name
]
!==
self
::
$null
)
$this
->
id
[
$name
]
=
$this
->
data
[
$name
];
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
();
$names
=
$this
->
_
table
->
getIdentifier
();
foreach
(
$names
as
$name
)
{
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
$this
->
id
[
$name
]
=
null
;
if
(
$this
->
_
data
[
$name
]
===
self
::
$null
)
$this
->
_
id
[
$name
]
=
null
;
else
$this
->
id
[
$name
]
=
$this
->
data
[
$name
];
$this
->
_id
[
$name
]
=
$this
->
_
data
[
$name
];
}
break
;
endswitch
;
...
...
@@ -429,29 +433,28 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return array
*/
public
function
serialize
()
{
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSleep
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSleep
(
$this
);
$vars
=
get_object_vars
(
$this
);
unset
(
$vars
[
'references'
]);
unset
(
$vars
[
'collections'
]);
unset
(
$vars
[
'originals'
]);
unset
(
$vars
[
'table'
]);
unset
(
$vars
[
'_table'
]);
$name
=
$this
->
table
->
getIdentifier
();
$this
->
data
=
array_merge
(
$this
->
data
,
$this
->
id
);
$name
=
$this
->
_
table
->
getIdentifier
();
$this
->
_data
=
array_merge
(
$this
->
_data
,
$this
->
_
id
);
foreach
(
$this
->
data
as
$k
=>
$v
)
{
foreach
(
$this
->
_
data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Record
)
unset
(
$vars
[
'data'
][
$k
]);
unset
(
$vars
[
'
_
data'
][
$k
]);
elseif
(
$v
===
self
::
$null
)
{
unset
(
$vars
[
'data'
][
$k
]);
unset
(
$vars
[
'
_
data'
][
$k
]);
}
else
{
switch
(
$this
->
table
->
getTypeOf
(
$k
))
:
switch
(
$this
->
_
table
->
getTypeOf
(
$k
))
:
case
"array"
:
case
"object"
:
$vars
[
'
data'
][
$k
]
=
serialize
(
$vars
[
'
data'
][
$k
]);
$vars
[
'
_data'
][
$k
]
=
serialize
(
$vars
[
'_
data'
][
$k
]);
break
;
endswitch
;
}
...
...
@@ -474,7 +477,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
oid
=
self
::
$index
;
self
::
$index
++
;
$this
->
table
=
$connection
->
getTable
(
get_class
(
$this
));
$this
->
_
table
=
$connection
->
getTable
(
get_class
(
$this
));
$array
=
unserialize
(
$serialized
);
...
...
@@ -483,13 +486,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
$name
=
$values
;
}
$this
->
table
->
getRepository
()
->
add
(
$this
);
$this
->
_
table
->
getRepository
()
->
add
(
$this
);
$this
->
cleanData
();
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
}
...
...
@@ -531,7 +534,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer
*/
final
public
function
getState
()
{
return
$this
->
state
;
return
$this
->
_
state
;
}
/**
* refresh
...
...
@@ -551,25 +554,25 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$id
=
array_values
(
$id
);
$query
=
$this
->
table
->
getQuery
()
.
" WHERE "
.
implode
(
" = ? AND "
,
$this
->
table
->
getPrimaryKeys
())
.
" = ?"
;
$stmt
=
$this
->
table
->
getConnection
()
->
execute
(
$query
,
$id
);
$query
=
$this
->
_table
->
getQuery
()
.
" WHERE "
.
implode
(
" = ? AND "
,
$this
->
_
table
->
getPrimaryKeys
())
.
" = ?"
;
$stmt
=
$this
->
_
table
->
getConnection
()
->
execute
(
$query
,
$id
);
$this
->
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
$this
->
_
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
!
$this
->
data
)
if
(
!
$this
->
_
data
)
throw
new
Doctrine_Record_Exception
(
'Failed to refresh. Record does not exist anymore'
);
$this
->
data
=
array_change_key_case
(
$this
->
data
,
CASE_LOWER
);
$this
->
_data
=
array_change_key_case
(
$this
->
_
data
,
CASE_LOWER
);
$this
->
modified
=
array
();
$this
->
_
modified
=
array
();
$this
->
cleanData
(
true
);
$this
->
prepareIdentifiers
();
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
return
true
;
}
...
...
@@ -581,20 +584,20 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
factoryRefresh
()
{
$this
->
data
=
$this
->
table
->
getData
();
$old
=
$this
->
id
;
$this
->
_data
=
$this
->
_
table
->
getData
();
$old
=
$this
->
_
id
;
$this
->
cleanData
();
$this
->
prepareIdentifiers
();
if
(
$this
->
id
!=
$old
)
if
(
$this
->
_
id
!=
$old
)
throw
new
Doctrine_Record_Exception
(
"The refreshed primary key doesn't match the one in the record memory."
,
Doctrine
::
ERR_REFRESH
);
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
modified
=
array
();
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
modified
=
array
();
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
}
/**
* getTable
...
...
@@ -603,7 +606,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return object Doctrine_Table a Doctrine_Table object
*/
final
public
function
getTable
()
{
return
$this
->
table
;
return
$this
->
_
table
;
}
/**
* getData
...
...
@@ -612,7 +615,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return array an array containing all the properties
*/
final
public
function
getData
()
{
return
$this
->
data
;
return
$this
->
_
data
;
}
/**
* rawGet
...
...
@@ -625,13 +628,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
rawGet
(
$name
)
{
if
(
!
isset
(
$this
->
data
[
$name
]))
if
(
!
isset
(
$this
->
_
data
[
$name
]))
throw
new
Doctrine_Record_Exception
(
'Unknown property '
.
$name
);
if
(
$this
->
data
[
$name
]
===
self
::
$null
)
if
(
$this
->
_
data
[
$name
]
===
self
::
$null
)
return
null
;
return
$this
->
data
[
$name
];
return
$this
->
_
data
[
$name
];
}
/**
...
...
@@ -642,7 +645,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
load
()
{
// only load the data from database if the Doctrine_Record is in proxy state
if
(
$this
->
state
==
Doctrine_Record
::
STATE_PROXY
)
{
if
(
$this
->
_
state
==
Doctrine_Record
::
STATE_PROXY
)
{
if
(
!
empty
(
$this
->
collections
))
{
// delegate the loading operation to collections in which this record resides
foreach
(
$this
->
collections
as
$collection
)
{
...
...
@@ -653,7 +656,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
refresh
();
}
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
return
true
;
}
...
...
@@ -670,31 +673,31 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
get
(
$name
,
$invoke
=
true
)
{
$listener
=
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
);
$listener
=
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
);
$value
=
self
::
$null
;
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
{
if
(
isset
(
$this
->
_
data
[
$lower
]))
{
// check if the property is null (= it is the Doctrine_Null object located in self::$null)
if
(
$this
->
data
[
$lower
]
===
self
::
$null
)
{
if
(
$this
->
_
data
[
$lower
]
===
self
::
$null
)
{
$this
->
load
();
}
if
(
$this
->
data
[
$lower
]
===
self
::
$null
)
if
(
$this
->
_
data
[
$lower
]
===
self
::
$null
)
$value
=
null
;
else
$value
=
$this
->
data
[
$lower
];
$value
=
$this
->
_
data
[
$lower
];
}
if
(
$value
!==
self
::
$null
)
{
$value
=
$this
->
table
->
invokeGet
(
$this
,
$name
,
$value
);
$value
=
$this
->
_
table
->
invokeGet
(
$this
,
$name
,
$value
);
if
(
$invoke
&&
$name
!==
$this
->
table
->
getIdentifier
())
return
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onGetProperty
(
$this
,
$name
,
$value
);
if
(
$invoke
&&
$name
!==
$this
->
_
table
->
getIdentifier
())
return
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onGetProperty
(
$this
,
$name
,
$value
);
else
return
$value
;
...
...
@@ -702,13 +705,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
if
(
isset
(
$this
->
id
[
$lower
]))
return
$this
->
id
[
$lower
];
if
(
isset
(
$this
->
_
id
[
$lower
]))
return
$this
->
_
id
[
$lower
];
if
(
$name
===
$this
->
table
->
getIdentifier
())
if
(
$name
===
$this
->
_
table
->
getIdentifier
())
return
null
;
$rel
=
$this
->
table
->
getRelation
(
$name
);
$rel
=
$this
->
_
table
->
getRelation
(
$name
);
try
{
if
(
!
isset
(
$this
->
references
[
$name
]))
...
...
@@ -737,7 +740,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
set
(
$name
,
$value
,
$load
=
true
)
{
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
{
if
(
isset
(
$this
->
_
data
[
$lower
]))
{
if
(
$value
instanceof
Doctrine_Record
)
{
$id
=
$value
->
getIncremented
();
...
...
@@ -749,25 +752,25 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$load
)
$old
=
$this
->
get
(
$lower
,
false
);
else
$old
=
$this
->
data
[
$lower
];
$old
=
$this
->
_
data
[
$lower
];
if
(
$old
!==
$value
)
{
$value
=
$this
->
table
->
invokeSet
(
$this
,
$name
,
$value
);
$value
=
$this
->
_
table
->
invokeSet
(
$this
,
$name
,
$value
);
$value
=
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSetProperty
(
$this
,
$name
,
$value
);
$value
=
$this
->
_
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSetProperty
(
$this
,
$name
,
$value
);
if
(
$value
===
null
)
$value
=
self
::
$null
;
$this
->
data
[
$lower
]
=
$value
;
$this
->
modified
[]
=
$lower
;
switch
(
$this
->
state
)
:
$this
->
_
data
[
$lower
]
=
$value
;
$this
->
_
modified
[]
=
$lower
;
switch
(
$this
->
_
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_DIRTY
;
$this
->
_
state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
$this
->
_
state
=
Doctrine_Record
::
STATE_TDIRTY
;
break
;
endswitch
;
}
...
...
@@ -781,7 +784,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
public
function
coreSetRelated
(
$name
,
$value
)
{
$rel
=
$this
->
table
->
getRelation
(
$name
);
$rel
=
$this
->
_
table
->
getRelation
(
$name
);
// one-to-many or one-to-one relation
if
(
$rel
instanceof
Doctrine_Relation_ForeignKey
||
...
...
@@ -822,10 +825,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
contains
(
$name
)
{
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
if
(
isset
(
$this
->
_
data
[
$lower
]))
return
true
;
if
(
isset
(
$this
->
id
[
$lower
]))
if
(
isset
(
$this
->
_
id
[
$lower
]))
return
true
;
if
(
isset
(
$this
->
references
[
$name
]))
...
...
@@ -838,8 +841,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
public
function
__unset
(
$name
)
{
if
(
isset
(
$this
->
data
[
$name
]))
$this
->
data
[
$name
]
=
array
();
if
(
isset
(
$this
->
_
data
[
$name
]))
$this
->
_
data
[
$name
]
=
array
();
// todo: what to do with references ?
}
...
...
@@ -854,7 +857,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
final
public
function
save
(
Doctrine_Connection
$conn
=
null
)
{
if
(
$conn
===
null
)
{
$conn
=
$this
->
table
->
getConnection
();
$conn
=
$this
->
_
table
->
getConnection
();
}
$conn
->
beginTransaction
();
...
...
@@ -868,7 +871,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$saveLater
as
$fk
)
{
$table
=
$fk
->
getTable
();
$alias
=
$this
->
table
->
getAlias
(
$table
->
getComponentName
());
$alias
=
$this
->
_
table
->
getAlias
(
$table
->
getComponentName
());
if
(
isset
(
$this
->
references
[
$alias
]))
{
$obj
=
$this
->
references
[
$alias
];
...
...
@@ -889,8 +892,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final
public
function
getModified
()
{
$a
=
array
();
foreach
(
$this
->
modified
as
$k
=>
$v
)
{
$a
[
$v
]
=
$this
->
data
[
$v
];
foreach
(
$this
->
_
modified
as
$k
=>
$v
)
{
$a
[
$v
]
=
$this
->
_
data
[
$v
];
}
return
$a
;
}
...
...
@@ -904,12 +907,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$a
=
array
();
if
(
empty
(
$array
))
$array
=
$this
->
modified
;
$array
=
$this
->
_
modified
;
foreach
(
$array
as
$k
=>
$v
)
{
$type
=
$this
->
table
->
getTypeOf
(
$v
);
$type
=
$this
->
_
table
->
getTypeOf
(
$v
);
if
(
$this
->
data
[
$v
]
===
self
::
$null
)
{
if
(
$this
->
_
data
[
$v
]
===
self
::
$null
)
{
$a
[
$v
]
=
null
;
continue
;
}
...
...
@@ -917,31 +920,31 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
switch
(
$type
)
{
case
'array'
:
case
'object'
:
$a
[
$v
]
=
serialize
(
$this
->
data
[
$v
]);
$a
[
$v
]
=
serialize
(
$this
->
_
data
[
$v
]);
break
;
case
'gzip'
:
$a
[
$v
]
=
gzcompress
(
$this
->
data
[
$v
],
5
);
$a
[
$v
]
=
gzcompress
(
$this
->
_
data
[
$v
],
5
);
break
;
case
'boolean'
:
$a
[
$v
]
=
(
int
)
$this
->
data
[
$v
];
$a
[
$v
]
=
(
int
)
$this
->
_
data
[
$v
];
break
;
case
'enum'
:
$a
[
$v
]
=
$this
->
table
->
enumIndex
(
$v
,
$this
->
data
[
$v
]);
$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
();
if
(
$this
->
_
data
[
$v
]
instanceof
Doctrine_Record
)
$this
->
_data
[
$v
]
=
$this
->
_
data
[
$v
]
->
getIncremented
();
$a
[
$v
]
=
$this
->
data
[
$v
];
$a
[
$v
]
=
$this
->
_
data
[
$v
];
}
}
foreach
(
$this
->
table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
foreach
(
$this
->
_
table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
$old
=
$this
->
get
(
$k
,
false
);
if
((
string
)
$old
!==
(
string
)
$v
||
$old
===
null
)
{
$a
[
$k
]
=
$v
;
$this
->
data
[
$k
]
=
$v
;
$this
->
_
data
[
$k
]
=
$v
;
}
}
...
...
@@ -954,7 +957,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer the number of columns
*/
public
function
count
()
{
return
count
(
$this
->
data
);
return
count
(
$this
->
_
data
);
}
/**
* alias for count()
...
...
@@ -976,8 +979,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$this
as
$column
=>
$value
)
{
$a
[
$column
]
=
$value
;
}
if
(
$this
->
table
->
getIdentifierType
()
==
Doctrine_Identifier
::
AUTO_INCREMENT
)
{
$i
=
$this
->
table
->
getIdentifier
();
if
(
$this
->
_
table
->
getIdentifierType
()
==
Doctrine_Identifier
::
AUTO_INCREMENT
)
{
$i
=
$this
->
_
table
->
getIdentifier
();
$a
[
$i
]
=
$this
->
getIncremented
();
}
return
$a
;
...
...
@@ -989,8 +992,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean
*/
public
function
exists
()
{
return
(
$this
->
state
!==
Doctrine_Record
::
STATE_TCLEAN
&&
$this
->
state
!==
Doctrine_Record
::
STATE_TDIRTY
);
return
(
$this
->
_
state
!==
Doctrine_Record
::
STATE_TCLEAN
&&
$this
->
_
state
!==
Doctrine_Record
::
STATE_TDIRTY
);
}
/**
* method for checking existence of properties and Doctrine_Record references
...
...
@@ -998,9 +1001,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean
*/
public
function
hasRelation
(
$name
)
{
if
(
isset
(
$this
->
data
[
$name
])
||
isset
(
$this
->
id
[
$name
]))
if
(
isset
(
$this
->
_data
[
$name
])
||
isset
(
$this
->
_
id
[
$name
]))
return
true
;
return
$this
->
table
->
hasRelation
(
$name
);
return
$this
->
_
table
->
hasRelation
(
$name
);
}
/**
* getIterator
...
...
@@ -1018,10 +1021,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
saveAssociations
()
{
foreach
(
$this
->
table
->
getRelations
()
as
$fk
)
{
foreach
(
$this
->
_
table
->
getRelations
()
as
$fk
)
{
$table
=
$fk
->
getTable
();
$name
=
$table
->
getComponentName
();
$alias
=
$this
->
table
->
getAlias
(
$name
);
$alias
=
$this
->
_
table
->
getAlias
(
$name
);
if
(
$fk
instanceof
Doctrine_Relation_Association
)
{
switch
(
$fk
->
getType
())
:
...
...
@@ -1041,7 +1044,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$r
as
$record
)
{
$query
=
"DELETE FROM "
.
$asf
->
getTableName
()
.
" WHERE "
.
$fk
->
getForeign
()
.
" = ?"
.
" AND "
.
$fk
->
getLocal
()
.
" = ?"
;
$this
->
table
->
getConnection
()
->
execute
(
$query
,
array
(
$record
->
getIncremented
(),
$this
->
getIncremented
()));
$this
->
_
table
->
getConnection
()
->
execute
(
$query
,
array
(
$record
->
getIncremented
(),
$this
->
getIncremented
()));
}
$r
=
Doctrine_Relation
::
getInsertOperations
(
$this
->
originals
[
$alias
],
$new
);
...
...
@@ -1104,7 +1107,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
delete
(
Doctrine_Connection
$conn
=
null
)
{
if
(
$conn
==
null
)
{
$conn
=
$this
->
table
->
getConnection
();
$conn
=
$this
->
_
table
->
getConnection
();
}
return
$conn
->
delete
(
$this
);
}
...
...
@@ -1115,7 +1118,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return Doctrine_Record
*/
public
function
copy
()
{
return
$this
->
table
->
create
(
$this
->
data
);
return
$this
->
_table
->
create
(
$this
->
_
data
);
}
/**
* assignIdentifier
...
...
@@ -1125,20 +1128,20 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
final
public
function
assignIdentifier
(
$id
=
false
)
{
if
(
$id
===
false
)
{
$this
->
id
=
array
();
$this
->
_
id
=
array
();
$this
->
cleanData
();
$this
->
state
=
Doctrine_Record
::
STATE_TCLEAN
;
$this
->
modified
=
array
();
$this
->
_
state
=
Doctrine_Record
::
STATE_TCLEAN
;
$this
->
_
modified
=
array
();
}
elseif
(
$id
===
true
)
{
$this
->
prepareIdentifiers
(
false
);
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
modified
=
array
();
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
modified
=
array
();
}
else
{
$name
=
$this
->
table
->
getIdentifier
();
$name
=
$this
->
_
table
->
getIdentifier
();
$this
->
id
[
$name
]
=
$id
;
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
modified
=
array
();
$this
->
_
id
[
$name
]
=
$id
;
$this
->
_
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_
modified
=
array
();
}
}
/**
...
...
@@ -1157,7 +1160,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return array
*/
final
public
function
obtainIdentifier
()
{
return
$this
->
id
;
return
$this
->
_
id
;
}
/**
* returns the value of autoincremented primary key of this object (if any)
...
...
@@ -1165,7 +1168,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer
*/
final
public
function
getIncremented
()
{
$id
=
current
(
$this
->
id
);
$id
=
current
(
$this
->
_
id
);
if
(
$id
===
false
)
return
null
;
...
...
@@ -1268,7 +1271,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
loadReference
(
$name
)
{
$fk
=
$this
->
table
->
getRelation
(
$name
);
$fk
=
$this
->
_
table
->
getRelation
(
$name
);
if
(
$fk
->
isOneToOne
())
{
$this
->
references
[
$name
]
=
$fk
->
fetchRelatedFor
(
$this
);
...
...
@@ -1301,7 +1304,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
ownsOne
(
$componentName
,
$foreignKey
,
$localKey
=
null
)
{
$this
->
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
ONE_COMPOSITE
,
$localKey
);
$this
->
_
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
ONE_COMPOSITE
,
$localKey
);
}
/**
* binds One-to-Many composite relation
...
...
@@ -1311,7 +1314,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
ownsMany
(
$componentName
,
$foreignKey
,
$localKey
=
null
)
{
$this
->
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
MANY_COMPOSITE
,
$localKey
);
$this
->
_
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
MANY_COMPOSITE
,
$localKey
);
}
/**
* binds One-to-One aggregate relation
...
...
@@ -1321,7 +1324,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
hasOne
(
$componentName
,
$foreignKey
,
$localKey
=
null
)
{
$this
->
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
ONE_AGGREGATE
,
$localKey
);
$this
->
_
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
ONE_AGGREGATE
,
$localKey
);
}
/**
* binds One-to-Many aggregate relation
...
...
@@ -1331,14 +1334,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
hasMany
(
$componentName
,
$foreignKey
,
$localKey
=
null
)
{
$this
->
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
MANY_AGGREGATE
,
$localKey
);
$this
->
_
table
->
bind
(
$componentName
,
$foreignKey
,
Doctrine_Relation
::
MANY_AGGREGATE
,
$localKey
);
}
/**
* setPrimaryKey
* @param mixed $key
*/
final
public
function
setPrimaryKey
(
$key
)
{
$this
->
table
->
setPrimaryKey
(
$key
);
$this
->
_
table
->
setPrimaryKey
(
$key
);
}
/**
* hasColumn
...
...
@@ -1351,7 +1354,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
final
public
function
hasColumn
(
$name
,
$type
,
$length
=
2147483647
,
$options
=
""
)
{
$this
->
table
->
setColumn
(
$name
,
$type
,
$length
,
$options
);
$this
->
_
table
->
setColumn
(
$name
,
$type
,
$length
,
$options
);
}
/**
* countRelated
...
...
@@ -1360,7 +1363,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return integer
*/
public
function
countRelated
(
$name
)
{
$rel
=
$this
->
table
->
getRelation
(
$name
);
$rel
=
$this
->
_
table
->
getRelation
(
$name
);
$componentName
=
$rel
->
getTable
()
->
getComponentName
();
$alias
=
$rel
->
getTable
()
->
getAlias
(
get_class
(
$this
));
$query
=
new
Doctrine_Query
();
...
...
@@ -1376,7 +1379,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void
*/
public
function
merge
(
array
$values
)
{
foreach
(
$this
->
table
->
getColumnNames
()
as
$value
)
{
foreach
(
$this
->
_
table
->
getColumnNames
()
as
$value
)
{
try
{
if
(
isset
(
$values
[
$value
]))
$this
->
set
(
$value
,
$values
[
$value
]);
...
...
@@ -1386,16 +1389,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
public
function
setAttribute
(
$attr
,
$value
)
{
$this
->
table
->
setAttribute
(
$attr
,
$value
);
$this
->
_
table
->
setAttribute
(
$attr
,
$value
);
}
public
function
setTableName
(
$tableName
)
{
$this
->
table
->
setTableName
(
$tableName
);
$this
->
_
table
->
setTableName
(
$tableName
);
}
public
function
setInheritanceMap
(
$map
)
{
$this
->
table
->
setInheritanceMap
(
$map
);
$this
->
_
table
->
setInheritanceMap
(
$map
);
}
public
function
setEnumValues
(
$column
,
$values
)
{
$this
->
table
->
setEnumValues
(
$column
,
$values
);
$this
->
_
table
->
setEnumValues
(
$column
,
$values
);
}
/**
* addListener
...
...
@@ -1404,7 +1407,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return Doctrine_DB
*/
public
function
addListener
(
$listener
,
$name
=
null
)
{
$this
->
table
->
addListener
(
$listener
,
$name
=
null
);
$this
->
_
table
->
addListener
(
$listener
,
$name
=
null
);
return
$this
;
}
/**
...
...
@@ -1413,7 +1416,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return Doctrine_DB_EventListener_Interface|Doctrine_Overloadable
*/
public
function
getListener
()
{
return
$this
->
table
->
getListener
();
return
$this
->
_
table
->
getListener
();
}
/**
* setListener
...
...
@@ -1422,7 +1425,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return Doctrine_DB
*/
public
function
setListener
(
$listener
)
{
$this
->
table
->
setListener
(
$listener
);
$this
->
_
table
->
setListener
(
$listener
);
return
$this
;
}
/**
...
...
@@ -1443,7 +1446,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$newvalue
=
call_user_func_array
(
$callback
,
$args
);
$this
->
data
[
$column
]
=
$newvalue
;
$this
->
_
data
[
$column
]
=
$newvalue
;
}
return
$this
;
}
...
...
manual/codes/Advanced components - Validators - More Validation.php
View file @
da6f4a38
...
...
@@ -15,7 +15,7 @@ class User extends Doctrine_Record {
if
(
$this
->
name
==
'God'
)
{
// Blasphemy! Stop that! ;-)
// syntax: add(<fieldName>, <error code/identifier>)
$this
->
errorStack
->
add
(
'name'
,
'forbiddenName'
);
$this
->
getErrorStack
()
->
add
(
'name'
,
'forbiddenName'
);
}
}
}
...
...
tests/classes.php
View file @
da6f4a38
...
...
@@ -101,17 +101,17 @@ class User extends Entity {
public
function
validate
()
{
// Allow only one name!
if
(
$this
->
name
!==
'The Saint'
)
{
$this
->
errorStack
->
add
(
'name'
,
'notTheSaint'
);
$this
->
getErrorStack
()
->
add
(
'name'
,
'notTheSaint'
);
}
}
public
function
validateOnInsert
()
{
if
(
$this
->
password
!==
'Top Secret'
)
{
$this
->
errorStack
->
add
(
'password'
,
'pwNotTopSecret'
);
$this
->
getErrorStack
()
->
add
(
'password'
,
'pwNotTopSecret'
);
}
}
public
function
validateOnUpdate
()
{
if
(
$this
->
loginname
!==
'Nobody'
)
{
$this
->
errorStack
->
add
(
'loginname'
,
'notNobody'
);
$this
->
getErrorStack
()
->
add
(
'loginname'
,
'notNobody'
);
}
}
}
...
...
tests/run.php
View file @
da6f4a38
...
...
@@ -53,16 +53,17 @@ print "<pre>";
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_Query_MultiJoin_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Relation_TestCase
());
$test
->
addTestCase
(
new
Doctrine_EventListenerTestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Transaction_TestCase
());
$test
->
addTestCase
(
new
Doctrine_ConnectionTestCase
());
...
...
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