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
e1fbae22
Commit
e1fbae22
authored
Jun 25, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EventListener method names updated
parent
628aac0e
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
306 additions
and
505 deletions
+306
-505
Connection.php
lib/Doctrine/Connection.php
+25
-23
Profiler.php
lib/Doctrine/Connection/Profiler.php
+1
-5
Statement.php
lib/Doctrine/Connection/Statement.php
+31
-22
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+4
-21
Event.php
lib/Doctrine/Event.php
+6
-4
EventListener.php
lib/Doctrine/EventListener.php
+22
-50
Chain.php
lib/Doctrine/EventListener/Chain.php
+49
-206
Interface.php
lib/Doctrine/EventListener/Interface.php
+20
-54
Manager.php
lib/Doctrine/Manager.php
+2
-2
Record.php
lib/Doctrine/Record.php
+0
-15
Transaction.php
lib/Doctrine/Transaction.php
+47
-42
ProfilerTestCase.php
tests/Connection/ProfilerTestCase.php
+15
-14
DBTestCase.php
tests/DBTestCase.php
+40
-37
HookTestCase.php
tests/Record/HookTestCase.php
+43
-9
classes.php
tests/classes.php
+1
-1
No files found.
lib/Doctrine/Connection.php
View file @
e1fbae22
...
@@ -64,10 +64,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -64,10 +64,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* keys representing Doctrine_Table component names and values as Doctrine_Table objects
* keys representing Doctrine_Table component names and values as Doctrine_Table objects
*/
*/
protected
$tables
=
array
();
protected
$tables
=
array
();
/**
* @var array $exported
*/
protected
$exported
=
array
();
/**
/**
* @var string $driverName the name of this connection driver
* @var string $driverName the name of this connection driver
*/
*/
...
@@ -331,7 +327,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -331,7 +327,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONNECT
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONNECT
);
$this
->
getListener
()
->
onP
reConnect
(
$event
);
$this
->
getListener
()
->
p
reConnect
(
$event
);
$e
=
explode
(
':'
,
$this
->
options
[
'dsn'
]);
$e
=
explode
(
':'
,
$this
->
options
[
'dsn'
]);
$found
=
false
;
$found
=
false
;
...
@@ -365,7 +361,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -365,7 +361,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this
->
isConnected
=
true
;
$this
->
isConnected
=
true
;
$this
->
getListener
()
->
on
Connect
(
$event
);
$this
->
getListener
()
->
post
Connect
(
$event
);
return
true
;
return
true
;
}
}
...
@@ -676,13 +672,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -676,13 +672,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
{
$this
->
connect
();
$this
->
connect
();
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_
Db_
Event
::
PREPARE
,
$statement
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
PREPARE
,
$statement
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onP
rePrepare
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
p
rePrepare
(
$event
);
$stmt
=
false
;
if
(
!
$event
->
skipOperation
)
{
$stmt
=
$this
->
dbh
->
prepare
(
$statement
);
$stmt
=
$this
->
dbh
->
prepare
(
$statement
);
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
on
Prepare
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
post
Prepare
(
$event
);
return
new
Doctrine_Connection_Statement
(
$this
,
$stmt
);
return
new
Doctrine_Connection_Statement
(
$this
,
$stmt
);
}
}
...
@@ -760,15 +760,16 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -760,15 +760,16 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$stmt
->
execute
(
$params
);
$stmt
->
execute
(
$params
);
return
$stmt
;
return
$stmt
;
}
else
{
}
else
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_E
VENT
::
QUERY
,
$query
,
$params
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_E
vent
::
QUERY
,
$query
,
$params
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onP
reQuery
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
p
reQuery
(
$event
);
if
(
!
$event
->
skipOperation
)
{
$stmt
=
$this
->
dbh
->
query
(
$query
);
$stmt
=
$this
->
dbh
->
query
(
$query
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onQuery
(
$event
);
$this
->
_count
++
;
$this
->
_count
++
;
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postQuery
(
$event
);
return
$stmt
;
return
$stmt
;
}
}
...
@@ -796,13 +797,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -796,13 +797,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
}
else
{
}
else
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_EVENT
::
EXEC
,
$query
,
$params
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_EVENT
::
EXEC
,
$query
,
$params
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onP
reExec
(
$event
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
p
reExec
(
$event
);
if
(
!
$event
->
skipOperation
)
{
$count
=
$this
->
dbh
->
exec
(
$query
);
$count
=
$this
->
dbh
->
exec
(
$query
);
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onExec
(
$event
);
$this
->
_count
++
;
$this
->
_count
++
;
}
$this
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postExec
(
$event
);
return
$count
;
return
$count
;
}
}
...
...
lib/Doctrine/Connection/Profiler.php
View file @
e1fbae22
...
@@ -80,12 +80,8 @@ class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAgg
...
@@ -80,12 +80,8 @@ class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAgg
throw
new
Doctrine_Connection_Profiler_Exception
(
"Couldn't listen event. Event should be an instance of Doctrine_Event."
);
throw
new
Doctrine_Connection_Profiler_Exception
(
"Couldn't listen event. Event should be an instance of Doctrine_Event."
);
}
}
// event methods should start with 'on'
if
(
substr
(
$m
,
0
,
2
)
!==
'on'
)
{
throw
new
Doctrine_Connection_Profiler_Exception
(
"Couldn't invoke listener :"
.
$m
);
}
if
(
substr
(
$m
,
2
,
3
)
===
'Pre'
&&
substr
(
$m
,
2
,
7
)
!==
'Prepa
re'
)
{
if
(
substr
(
$m
,
0
,
3
)
===
'p
re'
)
{
// pre-event listener found
// pre-event listener found
$a
[
0
]
->
start
();
$a
[
0
]
->
start
();
...
...
lib/Doctrine/Connection/Statement.php
View file @
e1fbae22
...
@@ -37,10 +37,10 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -37,10 +37,10 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
* statement holds an instance of Doctrine_Connection
* statement holds an instance of Doctrine_Connection
*/
*/
protected
$_conn
;
protected
$_conn
;
/**
* @var mixed $_stmt PDOStatement object, boolean false or Doctrine_Adapter_Statement object
*/
protected
$_stmt
;
protected
$_stmt
;
protected
$_executed
=
false
;
/**
/**
* constructor
* constructor
*
*
...
@@ -54,7 +54,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -54,7 +54,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
$this
->
_stmt
=
$stmt
;
$this
->
_stmt
=
$stmt
;
if
(
$stmt
===
false
)
{
if
(
$stmt
===
false
)
{
throw
new
Doctrine_
Db_
Exception
(
'Unknown statement object given.'
);
throw
new
Doctrine_Exception
(
'Unknown statement object given.'
);
}
}
}
}
/**
/**
...
@@ -215,14 +215,14 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -215,14 +215,14 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
{
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
EXECUTE
,
$this
->
_stmt
->
queryString
,
$params
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
EXECUTE
,
$this
->
_stmt
->
queryString
,
$params
);
// print $this->_stmt->queryString . print_r($params, true) . "<br>";
// print $this->_stmt->queryString . print_r($params, true) . "<br>";
$
skip
=
$this
->
_conn
->
getListener
()
->
onP
reExecute
(
$event
);
$
this
->
_conn
->
getListener
()
->
p
reExecute
(
$event
);
if
(
!
$
skip
)
{
if
(
!
$
event
->
skipOperation
)
{
$this
->
_stmt
->
execute
(
$params
);
$this
->
_stmt
->
execute
(
$params
);
$this
->
_conn
->
incrementQueryCount
();
$this
->
_conn
->
incrementQueryCount
();
}
}
$this
->
_conn
->
getListener
()
->
on
Execute
(
$event
);
$this
->
_conn
->
getListener
()
->
post
Execute
(
$event
);
return
$this
;
return
$this
;
}
}
...
@@ -253,20 +253,23 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -253,20 +253,23 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
*
*
* @return mixed
* @return mixed
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
Doctrine
::
FETCH_BOTH
,
public
function
fetch
(
$fetch
Mod
e
=
Doctrine
::
FETCH_BOTH
,
$cursorOrientation
=
Doctrine
::
FETCH_ORI_NEXT
,
$cursorOrientation
=
Doctrine
::
FETCH_ORI_NEXT
,
$cursorOffset
=
null
)
$cursorOffset
=
null
)
{
{
$event
=
new
Doctrine_Db_Event
(
$this
,
Doctrine_Db_Event
::
FETCHALL
,
$this
->
_stmt
->
getQuery
(),
$event
=
new
Doctrine_Db_Event
(
$this
,
Doctrine_Event
::
FETCHALL
,
$this
->
_stmt
->
getQuery
());
array
(
$fetchStyle
,
$cursorOrientation
,
$cursorOffset
));
$event
->
fetchMode
=
$fetchMode
;
$event
->
cursorOrientation
=
$cursorOrientation
;
$event
->
cursorOffset
=
$cursorOffset
;
$data
=
$this
->
_conn
->
getListener
()
->
onP
reFetch
(
$event
);
$data
=
$this
->
_conn
->
getListener
()
->
p
reFetch
(
$event
);
if
(
$data
===
null
)
{
if
(
!
$event
->
skipOperation
)
{
$data
=
$this
->
_stmt
->
fetch
(
$fetch
Styl
e
,
$cursorOrientation
,
$cursorOffset
);
$data
=
$this
->
_stmt
->
fetch
(
$fetch
Mod
e
,
$cursorOrientation
,
$cursorOffset
);
}
}
$this
->
_conn
->
getListener
()
->
on
Fetch
(
$event
);
$this
->
_conn
->
getListener
()
->
post
Fetch
(
$event
);
return
$data
;
return
$data
;
}
}
...
@@ -274,29 +277,35 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
...
@@ -274,29 +277,35 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
* fetchAll
* fetchAll
* Returns an array containing all of the result set rows
* Returns an array containing all of the result set rows
*
*
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Doctrine::FETCH_* constants,
* defaulting to Doctrine::FETCH_BOTH
*
*
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
* Doctrine::FETCH_COLUMN. Defaults to 0.
* Doctrine::FETCH_COLUMN. Defaults to 0.
*
*
* @return array
* @return array
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
Doctrine
::
FETCH_BOTH
,
public
function
fetchAll
(
$fetch
Mod
e
=
Doctrine
::
FETCH_BOTH
,
$columnIndex
=
null
)
$columnIndex
=
null
)
{
{
$event
=
new
Doctrine_Db_Event
(
$this
,
Doctrine_Db_Event
::
FETCHALL
,
$this
->
_stmt
->
getQuery
(),
array
(
$fetchStyle
,
$columnIndex
));
$event
=
new
Doctrine_Db_Event
(
$this
,
Doctrine_Event
::
FETCHALL
,
$this
->
_stmt
->
getQuery
());
$event
->
fetchMode
=
$fetchMode
;
$event
->
columnIndex
=
$columnIndex
;
$
data
=
$this
->
_conn
->
getListener
()
->
onP
reFetchAll
(
$event
);
$
this
->
_conn
->
getListener
()
->
p
reFetchAll
(
$event
);
if
(
$data
===
null
)
{
if
(
!
$event
->
skipOperation
)
{
if
(
$columnIndex
!==
null
)
{
if
(
$columnIndex
!==
null
)
{
$data
=
$this
->
_stmt
->
fetchAll
(
$fetch
Styl
e
,
$columnIndex
);
$data
=
$this
->
_stmt
->
fetchAll
(
$fetch
Mod
e
,
$columnIndex
);
}
else
{
}
else
{
$data
=
$this
->
_stmt
->
fetchAll
(
$fetch
Styl
e
);
$data
=
$this
->
_stmt
->
fetchAll
(
$fetch
Mod
e
);
}
}
$event
->
data
=
$data
;
}
}
$this
->
_conn
->
getListener
()
->
on
FetchAll
(
$event
);
$this
->
_conn
->
getListener
()
->
post
FetchAll
(
$event
);
return
$data
;
return
$data
;
}
}
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
e1fbae22
...
@@ -139,13 +139,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -139,13 +139,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*/
*/
public
function
save
(
Doctrine_Record
$record
)
public
function
save
(
Doctrine_Record
$record
)
{
{
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreSave
(
$record
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
SAVE
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
SAVE
);
$record
->
preSave
(
$event
);
$record
->
preSave
(
$event
);
if
(
!
$event
->
getOption
(
'skipOperation'
)
)
{
if
(
!
$event
->
skipOperation
)
{
switch
(
$record
->
state
())
{
switch
(
$record
->
state
())
{
case
Doctrine_Record
::
STATE_TDIRTY
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$this
->
insert
(
$record
);
$this
->
insert
(
$record
);
...
@@ -162,8 +160,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -162,8 +160,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
$record
->
postSave
(
$event
);
$record
->
postSave
(
$event
);
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onSave
(
$record
);
}
}
/**
/**
* deletes this data access object and all the related composites
* deletes this data access object and all the related composites
...
@@ -180,21 +176,17 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -180,21 +176,17 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
$this
->
conn
->
beginTransaction
();
$this
->
conn
->
beginTransaction
();
$record
->
getTable
()
->
getListener
()
->
onPreDelete
(
$record
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
DELETE
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
DELETE
);
$record
->
preDelete
(
$event
);
$record
->
preDelete
(
$event
);
$this
->
deleteComposites
(
$record
);
$this
->
deleteComposites
(
$record
);
if
(
!
$event
->
getOption
(
'skipOperation'
)
)
{
if
(
!
$event
->
skipOperation
)
{
$this
->
conn
->
transaction
->
addDelete
(
$record
);
$this
->
conn
->
transaction
->
addDelete
(
$record
);
$record
->
state
(
Doctrine_Record
::
STATE_TCLEAN
);
$record
->
state
(
Doctrine_Record
::
STATE_TCLEAN
);
}
}
$record
->
getTable
()
->
getListener
()
->
onDelete
(
$record
);
$record
->
postDelete
(
$event
);
$record
->
postDelete
(
$event
);
$this
->
conn
->
commit
();
$this
->
conn
->
commit
();
...
@@ -334,13 +326,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -334,13 +326,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*/
*/
public
function
update
(
Doctrine_Record
$record
)
public
function
update
(
Doctrine_Record
$record
)
{
{
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreUpdate
(
$record
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
UPDATE
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
UPDATE
);
$record
->
preUpdate
(
$event
);
$record
->
preUpdate
(
$event
);
if
(
!
$event
->
getOption
(
'skipOperation'
)
)
{
if
(
!
$event
->
skipOperation
)
{
$array
=
$record
->
getPrepared
();
$array
=
$record
->
getPrepared
();
if
(
empty
(
$array
))
{
if
(
empty
(
$array
))
{
...
@@ -380,8 +370,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -380,8 +370,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
$record
->
postUpdate
(
$event
);
$record
->
postUpdate
(
$event
);
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onUpdate
(
$record
);
return
true
;
return
true
;
}
}
/**
/**
...
@@ -393,13 +381,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -393,13 +381,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
public
function
insert
(
Doctrine_Record
$record
)
public
function
insert
(
Doctrine_Record
$record
)
{
{
// listen the onPreInsert event
// listen the onPreInsert event
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreInsert
(
$record
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
INSERT
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
INSERT
);
$record
->
preInsert
(
$event
);
$record
->
preInsert
(
$event
);
if
(
!
$event
->
getOption
(
'skipOperation'
)
)
{
if
(
!
$event
->
skipOperation
)
{
$array
=
$record
->
getPrepared
();
$array
=
$record
->
getPrepared
();
if
(
empty
(
$array
))
{
if
(
empty
(
$array
))
{
...
@@ -440,9 +426,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -440,9 +426,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
$record
->
postInsert
(
$event
);
$record
->
postInsert
(
$event
);
// listen the onInsert event
$table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onInsert
(
$record
);
return
true
;
return
true
;
}
}
}
}
lib/Doctrine/Event.php
View file @
e1fbae22
...
@@ -144,7 +144,7 @@ class Doctrine_Event
...
@@ -144,7 +144,7 @@ class Doctrine_Event
* @param string $option the name of the option
* @param string $option the name of the option
* @return mixed
* @return mixed
*/
*/
public
function
getOption
(
$option
)
public
function
__get
(
$option
)
{
{
if
(
!
isset
(
$this
->
_options
[
$option
]))
{
if
(
!
isset
(
$this
->
_options
[
$option
]))
{
return
null
;
return
null
;
...
@@ -155,13 +155,15 @@ class Doctrine_Event
...
@@ -155,13 +155,15 @@ class Doctrine_Event
/**
/**
* skipOperation
* skipOperation
* skips the next operation
* skips the next operation
* an alias for
setOption
('skipOperation', true)
* an alias for
__set
('skipOperation', true)
*
*
* @return Doctrine_Event this object
* @return Doctrine_Event this object
*/
*/
public
function
skipOperation
()
public
function
skipOperation
()
{
{
return
$this
->
setOption
(
'skipOperation'
,
true
);
$this
->
_options
[
'skipOperation'
]
=
true
;
return
$this
;
}
}
/**
/**
* setOption
* setOption
...
@@ -171,7 +173,7 @@ class Doctrine_Event
...
@@ -171,7 +173,7 @@ class Doctrine_Event
* @param mixed $value the value of the given option
* @param mixed $value the value of the given option
* @return Doctrine_Event this object
* @return Doctrine_Event this object
*/
*/
public
function
setOption
(
$option
,
$value
)
public
function
__set
(
$option
,
$value
)
{
{
$this
->
_options
[
$option
]
=
$value
;
$this
->
_options
[
$option
]
=
$value
;
...
...
lib/Doctrine/EventListener.php
View file @
e1fbae22
...
@@ -45,31 +45,6 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
...
@@ -45,31 +45,6 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
public
function
onWakeUp
(
Doctrine_Record
$record
)
public
function
onWakeUp
(
Doctrine_Record
$record
)
{
}
{
}
public
function
onUpdate
(
Doctrine_Record
$record
)
{
}
public
function
onPreUpdate
(
Doctrine_Record
$record
)
{
}
public
function
onCreate
(
Doctrine_Record
$record
)
{
}
public
function
onPreCreate
(
Doctrine_Record
$record
)
{
}
public
function
onSave
(
Doctrine_Record
$record
)
{
}
public
function
onPreSave
(
Doctrine_Record
$record
)
{
}
public
function
onInsert
(
Doctrine_Record
$record
)
{
}
public
function
onPreInsert
(
Doctrine_Record
$record
)
{
}
public
function
onDelete
(
Doctrine_Record
$record
)
{
}
public
function
onPreDelete
(
Doctrine_Record
$record
)
{
}
public
function
onEvict
(
Doctrine_Record
$record
)
public
function
onEvict
(
Doctrine_Record
$record
)
{
}
{
}
public
function
onPreEvict
(
Doctrine_Record
$record
)
public
function
onPreEvict
(
Doctrine_Record
$record
)
...
@@ -88,56 +63,53 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
...
@@ -88,56 +63,53 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
public
function
onOpen
(
Doctrine_Connection
$connection
)
public
function
onOpen
(
Doctrine_Connection
$connection
)
{
}
{
}
public
function
preTransactionCommit
(
Doctrine_Event
$event
)
public
function
onTransactionCommit
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onPre
TransactionCommit
(
Doctrine_Event
$event
)
public
function
post
TransactionCommit
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
TransactionRollback
(
Doctrine_Event
$event
)
public
function
pre
TransactionRollback
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onPre
TransactionRollback
(
Doctrine_Event
$event
)
public
function
post
TransactionRollback
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
TransactionBegin
(
Doctrine_Event
$event
)
public
function
pre
TransactionBegin
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onPre
TransactionBegin
(
Doctrine_Event
$event
)
public
function
post
TransactionBegin
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Connect
(
Doctrine_Event
$event
)
public
function
post
Connect
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
reConnect
(
Doctrine_Event
$event
)
public
function
p
reConnect
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onPreQuery
(
Doctrine_Event
$event
)
public
function
preQuery
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Query
(
Doctrine_Event
$event
)
public
function
post
Query
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
rePrepare
(
Doctrine_Event
$event
)
public
function
p
rePrepare
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Prepare
(
Doctrine_Event
$event
)
public
function
post
Prepare
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
reExec
(
Doctrine_Event
$event
)
public
function
p
reExec
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Exec
(
Doctrine_Event
$event
)
public
function
post
Exec
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
reFetch
(
Doctrine_Event
$event
)
public
function
p
reFetch
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Fetch
(
Doctrine_Event
$event
)
public
function
post
Fetch
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
reFetchAll
(
Doctrine_Event
$event
)
public
function
p
reFetchAll
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
FetchAll
(
Doctrine_Event
$event
)
public
function
post
FetchAll
(
Doctrine_Event
$event
)
{
}
{
}
public
function
onP
reExecute
(
Doctrine_Event
$event
)
public
function
p
reExecute
(
Doctrine_Event
$event
)
{
}
{
}
public
function
on
Execute
(
Doctrine_Event
$event
)
public
function
post
Execute
(
Doctrine_Event
$event
)
{
}
{
}
}
}
lib/Doctrine/EventListener/Chain.php
View file @
e1fbae22
...
@@ -138,163 +138,6 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -138,163 +138,6 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
$listener
->
onWakeUp
(
$record
);
$listener
->
onWakeUp
(
$record
);
}
}
}
}
/**
* onUpdate
* an event invoked after Doctrine_Record is updated
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onUpdate
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onUpdate
(
$record
);
}
}
/**
* onPreUpdate
* an event invoked before Doctrine_Record is updated
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreUpdate
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreUpdate
(
$record
);
}
}
/**
* onCreate
* an event invoked when a new Doctrine_Record is created
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onCreate
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onCreate
(
$record
);
}
}
/**
* onPreCreate
* an event invoked when a new Doctrine_Record
* but not yet initialized
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreCreate
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreCreate
(
$record
);
}
}
/**
* onSave
* an event invoked after a Doctrine_Record is saved (inserted / updated)
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onSave
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onSave
(
$record
);
}
}
/**
* onSave
* an event invoked after a Doctrine_Record is saved (inserted / updated)
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreSave
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreSave
(
$record
);
}
}
/**
* onInsert
* an event invoked after Doctrine_Record is inserted into database
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onInsert
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onInsert
(
$record
);
}
}
/**
* onPreInsert
* an event invoked before Doctrine_Record is inserted into database
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreInsert
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreInsert
(
$record
);
}
}
/**
* onDelete
* an event invoked after Doctrine_Record is deleted from database
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onDelete
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onDelete
(
$record
);
}
}
/**
* onPreDelete
* an event invoked before Doctrine_Record is deleted from database
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreDelete
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreDelete
(
$record
);
}
}
/**
* onEvict
* an event invoked after Doctrine_Record is evicted from record repository
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onEvict
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onEvict
(
$record
);
}
}
/**
* onPreEvict
* an event invoked before Doctrine_Record is evicted from record repository
*
* @param Doctrine_Record $record
* @return void
*/
public
function
onPreEvict
(
Doctrine_Record
$record
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onPreEvict
(
$record
);
}
}
/**
/**
* onClose
* onClose
* an event invoked after Doctrine_Connection is closed
* an event invoked after Doctrine_Connection is closed
...
@@ -341,10 +184,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -341,10 +184,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
on
TransactionCommit
(
Doctrine_Event
$event
)
public
function
post
TransactionCommit
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
TransactionCommit
(
$event
);
$listener
->
post
TransactionCommit
(
$event
);
}
}
}
}
/**
/**
...
@@ -354,10 +197,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -354,10 +197,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
onP
reTransactionCommit
(
Doctrine_Event
$event
)
public
function
p
reTransactionCommit
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reTransactionCommit
(
$event
);
$listener
->
p
reTransactionCommit
(
$event
);
}
}
}
}
/**
/**
...
@@ -367,10 +210,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -367,10 +210,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
on
TransactionRollback
(
Doctrine_Event
$event
)
public
function
post
TransactionRollback
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
TransactionRollback
(
$event
);
$listener
->
post
TransactionRollback
(
$event
);
}
}
}
}
/**
/**
...
@@ -380,10 +223,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -380,10 +223,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
onP
reTransactionRollback
(
Doctrine_Event
$event
)
public
function
p
reTransactionRollback
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reTransactionRollback
(
$event
);
$listener
->
p
reTransactionRollback
(
$event
);
}
}
}
}
/**
/**
...
@@ -393,10 +236,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -393,10 +236,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
on
TransactionBegin
(
Doctrine_Event
$event
)
public
function
post
TransactionBegin
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
TransactionBegin
(
$event
);
$listener
->
post
TransactionBegin
(
$event
);
}
}
}
}
/**
/**
...
@@ -406,10 +249,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -406,10 +249,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
* @param Doctrine_Event $event
* @param Doctrine_Event $event
* @return void
* @return void
*/
*/
public
function
onP
reTransactionBegin
(
Doctrine_Event
$event
)
public
function
p
reTransactionBegin
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reTransactionBegin
(
$event
);
$listener
->
p
reTransactionBegin
(
$event
);
}
}
}
}
/**
/**
...
@@ -438,95 +281,95 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
...
@@ -438,95 +281,95 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
$listener
->
onPreCollectionDelete
(
$collection
);
$listener
->
onPreCollectionDelete
(
$collection
);
}
}
}
}
public
function
on
Connect
(
Doctrine_Event
$event
)
public
function
post
Connect
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Connect
(
$event
);
$listener
->
post
Connect
(
$event
);
}
}
}
}
public
function
onP
reConnect
(
Doctrine_Event
$event
)
public
function
p
reConnect
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reConnect
(
$event
);
$listener
->
p
reConnect
(
$event
);
}
}
}
}
public
function
onP
reQuery
(
Doctrine_Event
$event
)
public
function
p
reQuery
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reQuery
(
$event
);
$listener
->
p
reQuery
(
$event
);
}
}
}
}
public
function
on
Query
(
Doctrine_Event
$event
)
public
function
post
Query
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Query
(
$event
);
$listener
->
post
Query
(
$event
);
}
}
}
}
public
function
onP
rePrepare
(
Doctrine_Event
$event
)
public
function
p
rePrepare
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
rePrepare
(
$event
);
$listener
->
p
rePrepare
(
$event
);
}
}
}
}
public
function
on
Prepare
(
Doctrine_Event
$event
)
public
function
post
Prepare
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Prepare
(
$event
);
$listener
->
post
Prepare
(
$event
);
}
}
}
}
public
function
onP
reExec
(
Doctrine_Event
$event
)
public
function
p
reExec
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reExec
(
$event
);
$listener
->
p
reExec
(
$event
);
}
}
}
}
public
function
on
Exec
(
Doctrine_Event
$event
)
public
function
post
Exec
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Exec
(
$event
);
$listener
->
post
Exec
(
$event
);
}
}
}
}
public
function
onP
reFetch
(
Doctrine_Event
$event
)
public
function
p
reFetch
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reFetch
(
$event
);
$listener
->
p
reFetch
(
$event
);
}
}
}
}
public
function
on
Fetch
(
Doctrine_Event
$event
)
public
function
post
Fetch
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Fetch
(
$event
);
$listener
->
post
Fetch
(
$event
);
}
}
}
}
public
function
onP
reFetchAll
(
Doctrine_Event
$event
)
public
function
p
reFetchAll
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reFetchAll
(
$event
);
$listener
->
p
reFetchAll
(
$event
);
}
}
}
}
public
function
on
FetchAll
(
Doctrine_Event
$event
)
public
function
post
FetchAll
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
FetchAll
(
$event
);
$listener
->
post
FetchAll
(
$event
);
}
}
}
}
public
function
onP
reExecute
(
Doctrine_Event
$event
)
public
function
p
reExecute
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
onP
reExecute
(
$event
);
$listener
->
p
reExecute
(
$event
);
}
}
}
}
public
function
on
Execute
(
Doctrine_Event
$event
)
public
function
post
Execute
(
Doctrine_Event
$event
)
{
{
foreach
(
$this
->
listeners
as
$listener
)
{
foreach
(
$this
->
listeners
as
$listener
)
{
$listener
->
on
Execute
(
$event
);
$listener
->
post
Execute
(
$event
);
}
}
}
}
}
}
lib/Doctrine/EventListener/Interface.php
View file @
e1fbae22
...
@@ -34,67 +34,33 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
...
@@ -34,67 +34,33 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
*/
*/
interface
Doctrine_EventListener_Interface
interface
Doctrine_EventListener_Interface
{
{
public
function
onLoad
(
Doctrine_Record
$record
);
public
function
preTransactionCommit
(
Doctrine_Event
$event
);
public
function
onPreLoad
(
Doctrine_Record
$record
);
public
function
postTransactionCommit
(
Doctrine_Event
$event
);
public
function
onSleep
(
Doctrine_Record
$record
);
public
function
preTransactionRollback
(
Doctrine_Event
$event
);
public
function
onWakeUp
(
Doctrine_Record
$record
);
public
function
postTransactionRollback
(
Doctrine_Event
$event
);
public
function
onUpdate
(
Doctrine_Record
$record
);
public
function
preTransactionBegin
(
Doctrine_Event
$event
);
public
function
onPreUpdate
(
Doctrine_Record
$record
);
public
function
postTransactionBegin
(
Doctrine_Event
$event
);
public
function
onCreate
(
Doctrine_Record
$record
);
public
function
postConnect
(
Doctrine_Event
$event
);
public
function
onPreCreate
(
Doctrine_Record
$record
);
public
function
preConnect
(
Doctrine_Event
$event
);
public
function
onSave
(
Doctrine_Record
$record
);
public
function
preQuery
(
Doctrine_Event
$event
);
public
function
onPreSave
(
Doctrine_Record
$record
);
public
function
postQuery
(
Doctrine_Event
$event
);
public
function
onInsert
(
Doctrine_Record
$record
);
public
function
prePrepare
(
Doctrine_Event
$event
);
public
function
onPreInsert
(
Doctrine_Record
$record
);
public
function
postPrepare
(
Doctrine_Event
$event
);
public
function
onDelete
(
Doctrine_Record
$record
);
public
function
preExec
(
Doctrine_Event
$event
);
public
function
onPreDelete
(
Doctrine_Record
$record
);
public
function
postExec
(
Doctrine_Event
$event
);
public
function
onEvict
(
Doctrine_Record
$record
);
public
function
preFetch
(
Doctrine_Event
$event
);
public
function
onPreEvict
(
Doctrine_Record
$record
);
public
function
postFetch
(
Doctrine_Event
$event
);
public
function
onClose
(
Doctrine_Event
$event
);
public
function
preFetchAll
(
Doctrine_Event
$event
);
public
function
onPreClose
(
Doctrine_Event
$event
);
public
function
postFetchAll
(
Doctrine_Event
$event
);
public
function
onCollectionDelete
(
Doctrine_Collection
$collection
);
public
function
preExecute
(
Doctrine_Event
$event
);
public
function
onPreCollectionDelete
(
Doctrine_Collection
$collection
);
public
function
postExecute
(
Doctrine_Event
$event
);
public
function
onOpen
(
Doctrine_Connection
$connection
);
public
function
onConnect
(
Doctrine_Event
$event
);
public
function
onPreConnect
(
Doctrine_Event
$event
);
public
function
onTransactionCommit
(
Doctrine_Event
$event
);
public
function
onPreTransactionCommit
(
Doctrine_Event
$event
);
public
function
onTransactionRollback
(
Doctrine_Event
$event
);
public
function
onPreTransactionRollback
(
Doctrine_Event
$event
);
public
function
onTransactionBegin
(
Doctrine_Event
$event
);
public
function
onPreTransactionBegin
(
Doctrine_Event
$event
);
public
function
onPreQuery
(
Doctrine_Event
$event
);
public
function
onQuery
(
Doctrine_Event
$event
);
public
function
onPrePrepare
(
Doctrine_Event
$event
);
public
function
onPrepare
(
Doctrine_Event
$event
);
public
function
onPreExec
(
Doctrine_Event
$event
);
public
function
onExec
(
Doctrine_Event
$event
);
public
function
onPreFetch
(
Doctrine_Event
$event
);
public
function
onFetch
(
Doctrine_Event
$event
);
public
function
onPreFetchAll
(
Doctrine_Event
$event
);
public
function
onFetchAll
(
Doctrine_Event
$event
);
public
function
onPreExecute
(
Doctrine_Event
$event
);
public
function
onExecute
(
Doctrine_Event
$event
);
}
}
lib/Doctrine/Manager.php
View file @
e1fbae22
...
@@ -322,7 +322,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -322,7 +322,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
case
'mock'
:
case
'mock'
:
case
'oracle'
:
case
'oracle'
:
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
if
(
!
isset
(
$parts
[
'path'
])
||
$parts
[
'path'
]
==
'/'
)
{
throw
new
Doctrine_
Db
_Exception
(
'No database availible in data source name'
);
throw
new
Doctrine_
Manager
_Exception
(
'No database availible in data source name'
);
}
}
if
(
isset
(
$parts
[
'path'
]))
{
if
(
isset
(
$parts
[
'path'
]))
{
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
$parts
[
'database'
]
=
substr
(
$parts
[
'path'
],
1
);
...
@@ -345,7 +345,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -345,7 +345,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
}
break
;
break
;
default
:
default
:
throw
new
Doctrine_
Db
_Exception
(
'Unknown driver '
.
$parts
[
'scheme'
]);
throw
new
Doctrine_
Manager
_Exception
(
'Unknown driver '
.
$parts
[
'scheme'
]);
}
}
...
...
lib/Doctrine/Record.php
View file @
e1fbae22
...
@@ -157,14 +157,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -157,14 +157,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$keys
=
$this
->
_table
->
getPrimaryKeys
();
$keys
=
$this
->
_table
->
getPrimaryKeys
();
if
(
!
$exists
)
{
// listen the onPreCreate event
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreCreate
(
$this
);
}
else
{
// listen the onPreLoad event
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreLoad
(
$this
);
}
// get the data array
// get the data array
$this
->
_data
=
$this
->
_table
->
getData
();
$this
->
_data
=
$this
->
_table
->
getData
();
...
@@ -185,19 +177,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -185,19 +177,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// set the default values for this record
// set the default values for this record
$this
->
assignDefaultValues
();
$this
->
assignDefaultValues
();
// listen the onCreate event
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onCreate
(
$this
);
}
else
{
}
else
{
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
_state
=
Doctrine_Record
::
STATE_CLEAN
;
if
(
$count
<
$this
->
_table
->
getColumnCount
())
{
if
(
$count
<
$this
->
_table
->
getColumnCount
())
{
$this
->
_state
=
Doctrine_Record
::
STATE_PROXY
;
$this
->
_state
=
Doctrine_Record
::
STATE_PROXY
;
}
}
// listen the onLoad event
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
}
}
$this
->
_errorStack
=
new
Doctrine_Validator_ErrorStack
();
$this
->
_errorStack
=
new
Doctrine_Validator_ErrorStack
();
...
...
lib/Doctrine/Transaction.php
View file @
e1fbae22
...
@@ -224,7 +224,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -224,7 +224,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
if
(
$this
->
transactionLevel
==
0
)
{
if
(
$this
->
transactionLevel
==
0
)
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
BEGIN
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
BEGIN
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onP
reTransactionBegin
(
$event
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
p
reTransactionBegin
(
$event
);
try
{
try
{
$this
->
conn
->
getDbh
()
->
beginTransaction
();
$this
->
conn
->
getDbh
()
->
beginTransaction
();
...
@@ -232,7 +232,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -232,7 +232,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
throw
new
Doctrine_Transaction_Exception
(
$e
->
getMessage
());
throw
new
Doctrine_Transaction_Exception
(
$e
->
getMessage
());
}
}
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
on
TransactionBegin
(
$event
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
post
TransactionBegin
(
$event
);
}
}
}
}
...
@@ -246,7 +246,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -246,7 +246,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
* progress or release a savepoint. This function may only be called when
* progress or release a savepoint. This function may only be called when
* auto-committing is disabled, otherwise it will fail.
* auto-committing is disabled, otherwise it will fail.
*
*
* Listeners:
onPreTransactionCommit, on
TransactionCommit
* Listeners:
preTransactionCommit, post
TransactionCommit
*
*
* @param string $savepoint name of a savepoint to release
* @param string $savepoint name of a savepoint to release
* @throws Doctrine_Transaction_Exception if the transaction fails at database level
* @throws Doctrine_Transaction_Exception if the transaction fails at database level
...
@@ -268,8 +268,10 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -268,8 +268,10 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
}
else
{
}
else
{
if
(
$this
->
transactionLevel
==
1
)
{
if
(
$this
->
transactionLevel
==
1
)
{
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
COMMIT
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
COMMIT
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreTransactionCommit
(
$event
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
preTransactionCommit
(
$event
);
if
(
!
$event
->
skipOperation
)
{
try
{
try
{
$this
->
bulkDelete
();
$this
->
bulkDelete
();
...
@@ -296,8 +298,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -296,8 +298,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
$this
->
conn
->
getDbh
()
->
commit
();
$this
->
conn
->
getDbh
()
->
commit
();
//$this->conn->unitOfWork->reset();
//$this->conn->unitOfWork->reset();
}
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
on
TransactionCommit
(
$event
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
post
TransactionCommit
(
$event
);
}
}
}
}
...
@@ -327,16 +330,16 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -327,16 +330,16 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
return
false
;
return
false
;
}
}
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
ROLLBACK
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreTransactionRollback
(
$event
);
if
(
!
is_null
(
$savepoint
))
{
if
(
!
is_null
(
$savepoint
))
{
$this
->
transactionLevel
=
$this
->
removeSavePoints
(
$savepoint
);
$this
->
transactionLevel
=
$this
->
removeSavePoints
(
$savepoint
);
$this
->
rollbackSavePoint
(
$savepoint
);
$this
->
rollbackSavePoint
(
$savepoint
);
}
else
{
}
else
{
//$this->conn->unitOfWork->reset();
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
ROLLBACK
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
preTransactionRollback
(
$event
);
if
(
!
$event
->
skipOperation
)
{
$this
->
deteles
=
array
();
$this
->
deteles
=
array
();
$this
->
transactionLevel
=
0
;
$this
->
transactionLevel
=
0
;
...
@@ -346,7 +349,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -346,7 +349,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
throw
new
Doctrine_Transaction_Exception
(
$e
->
getMessage
());
throw
new
Doctrine_Transaction_Exception
(
$e
->
getMessage
());
}
}
}
}
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onTransactionRollback
(
$event
);
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
postTransactionRollback
(
$event
);
}
return
true
;
return
true
;
}
}
...
...
tests/Connection/ProfilerTestCase.php
View file @
e1fbae22
...
@@ -39,6 +39,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -39,6 +39,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
{}
{}
public
function
setUp
()
public
function
setUp
()
{}
{}
public
function
testQuery
()
public
function
testQuery
()
{
{
$this
->
conn
=
Doctrine_Manager
::
getInstance
()
->
openConnection
(
array
(
'sqlite::memory:'
));
$this
->
conn
=
Doctrine_Manager
::
getInstance
()
->
openConnection
(
array
(
'sqlite::memory:'
));
...
@@ -51,12 +52,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -51,12 +52,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'CREATE TABLE test (id INT)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'CREATE TABLE test (id INT)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
EXEC
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
EXEC
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
conn
->
count
(),
1
);
$this
->
assertEqual
(
$this
->
conn
->
count
(),
1
);
}
}
/**
public
function
testPrepareAndExecute
()
public
function
testPrepareAndExecute
()
{
{
...
@@ -65,32 +66,32 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -65,32 +66,32 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$event
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$event
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_
Db_
Event::PREPARE);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$stmt
->
execute
(
array
(
1
));
$stmt
->
execute
(
array
(
1
));
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_
Db_
Event::EXECUTE);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
conn
->
count
(),
2
);
$this
->
assertEqual
(
$this
->
conn
->
count
(),
2
);
}
}
*/
public
function
testMultiplePrepareAndExecute
()
public
function
testMultiplePrepareAndExecute
()
{
{
$stmt
=
$this
->
conn
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$stmt
=
$this
->
conn
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
PREPARE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$stmt2
=
$this
->
conn
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$stmt2
=
$this
->
conn
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
PREPARE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
/** TODO: strange errors here
/** TODO: strange errors here
$stmt->execute(array(1));
$stmt->execute(array(1));
...
@@ -98,7 +99,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -98,7 +99,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_
Db_
Event::EXECUTE);
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE);
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
$this->assertEqual($this->conn->count(), 4);
$this->assertEqual($this->conn->count(), 4);
...
@@ -117,12 +118,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -117,12 +118,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
}
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
}
public
function
testTransactionRollback
()
public
function
testTransactionRollback
()
...
@@ -135,7 +136,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -135,7 +136,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
}
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
BEGIN
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
BEGIN
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
try
{
try
{
...
@@ -147,7 +148,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -147,7 +148,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
ROLLBACK
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
ROLLBACK
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
}
public
function
testTransactionCommit
()
public
function
testTransactionCommit
()
...
@@ -160,7 +161,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -160,7 +161,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
}
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
BEGIN
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
BEGIN
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
try
{
try
{
...
@@ -173,7 +174,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
...
@@ -173,7 +174,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_
Db_
Event
::
COMMIT
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getCode
(),
Doctrine_Event
::
COMMIT
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
}
}
}
...
...
tests/DBTestCase.php
View file @
e1fbae22
...
@@ -110,33 +110,33 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
...
@@ -110,33 +110,33 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
$listener
=
$this
->
dbh
->
getListener
();
$listener
=
$this
->
dbh
->
getListener
();
$stmt
=
$this
->
dbh
->
prepare
(
'INSERT INTO entity (id) VALUES(?)'
);
$stmt
=
$this
->
dbh
->
prepare
(
'INSERT INTO entity (id) VALUES(?)'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Prepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Prepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
rePrepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
rePrepare'
);
$stmt
->
execute
(
array
(
1
));
$stmt
->
execute
(
array
(
1
));
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Execute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Execute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExecute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExecute'
);
$this
->
dbh
->
exec
(
'DELETE FROM entity'
);
$this
->
dbh
->
exec
(
'DELETE FROM entity'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExec'
);
$this
->
dbh
->
beginTransaction
();
$this
->
dbh
->
beginTransaction
();
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
TransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
TransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reTransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reTransactionBegin'
);
$this
->
dbh
->
exec
(
'INSERT INTO entity (id) VALUES (1)'
);
$this
->
dbh
->
exec
(
'INSERT INTO entity (id) VALUES (1)'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExec'
);
$this
->
dbh
->
commit
();
$this
->
dbh
->
commit
();
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
TransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
TransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reTransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reTransactionCommit'
);
...
@@ -152,63 +152,66 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
...
@@ -152,63 +152,66 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
p
reExec'
);
}
}
public
function
testListeningPrepareEventsWithListenerChain
()
public
function
testListeningPrepareEventsWithListenerChain
()
{
{
$stmt
=
$this
->
dbh
->
prepare
(
'INSERT INTO entity (id) VALUES(?)'
);
$stmt
=
$this
->
dbh
->
prepare
(
'INSERT INTO entity (id) VALUES(?)'
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Prepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Prepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
rePrepare'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
rePrepare'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
on
Prepare'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
post
Prepare'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
onP
rePrepare'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
p
rePrepare'
);
$stmt
->
execute
(
array
(
1
));
$stmt
->
execute
(
array
(
1
));
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Execute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Execute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExecute'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExecute'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
on
Execute'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
post
Execute'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
onP
reExecute'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
p
reExecute'
);
}
}
public
function
testListeningExecEventsWithListenerChain
()
public
function
testListeningExecEventsWithListenerChain
()
{
{
$this
->
dbh
->
exec
(
'DELETE FROM entity'
);
$this
->
dbh
->
exec
(
'DELETE FROM entity'
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
p
reExec'
);
}
}
public
function
testListeningTransactionEventsWithListenerChain
()
public
function
testListeningTransactionEventsWithListenerChain
()
{
{
$this
->
dbh
->
beginTransaction
();
$this
->
dbh
->
beginTransaction
();
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener
=
$this
->
dbh
->
getListener
()
->
get
(
0
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$listener2
=
$this
->
dbh
->
getListener
()
->
get
(
1
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
TransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
TransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reTransactionBegin'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reTransactionBegin'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
on
TransactionBegin'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
post
TransactionBegin'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
onP
reTransactionBegin'
);
$this
->
assertEqual
(
$listener2
->
pop
(),
'
p
reTransactionBegin'
);
$this
->
dbh
->
exec
(
'INSERT INTO entity (id) VALUES (1)'
);
$this
->
dbh
->
exec
(
'INSERT INTO entity (id) VALUES (1)'
);
$this
->
dbh
->
commit
();
$this
->
dbh
->
commit
();
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
TransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
TransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reTransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reTransactionCommit'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
on
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
post
Exec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
onP
reExec'
);
$this
->
assertEqual
(
$listener
->
pop
(),
'
p
reExec'
);
$this
->
dbh
->
exec
(
'DROP TABLE entity'
);
$this
->
dbh
->
exec
(
'DROP TABLE entity'
);
}
}
...
...
tests/Record/HookTestCase.php
View file @
e1fbae22
...
@@ -36,7 +36,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
...
@@ -36,7 +36,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
{
}
{
}
public
function
prepareTables
()
public
function
prepareTables
()
{
{
$this
->
tables
=
array
(
'RecordHookTest'
);
$this
->
tables
=
array
(
'RecordHookTest'
,
'SoftDeleteTest'
);
parent
::
prepareTables
();
parent
::
prepareTables
();
}
}
...
@@ -78,7 +78,41 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
...
@@ -78,7 +78,41 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$r
->
pop
(),
'postDelete'
);
$this
->
assertEqual
(
$r
->
pop
(),
'postDelete'
);
$this
->
assertEqual
(
$r
->
pop
(),
'preDelete'
);
$this
->
assertEqual
(
$r
->
pop
(),
'preDelete'
);
}
}
public
function
testSoftDelete
()
{
$r
=
new
SoftDeleteTest
();
$r
->
name
=
'something'
;
$r
->
save
();
$this
->
assertEqual
(
$r
->
name
,
'something'
);
$this
->
assertEqual
(
$r
->
deleted
,
null
);
$this
->
assertEqual
(
$r
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$r
->
delete
();
$this
->
assertEqual
(
$r
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$r
->
deleted
,
true
);
}
}
}
class
SoftDeleteTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
null
,
array
(
'primary'
=>
true
));
$this
->
hasColumn
(
'deleted'
,
'boolean'
,
1
);
}
public
function
preDelete
(
$event
)
{
$event
->
skipOperation
();
}
public
function
postDelete
(
$event
)
{
$this
->
deleted
=
true
;
$this
->
save
();
}
}
class
RecordHookTest
extends
Doctrine_Record
class
RecordHookTest
extends
Doctrine_Record
{
{
protected
$_messages
=
array
();
protected
$_messages
=
array
();
...
@@ -87,35 +121,35 @@ class RecordHookTest extends Doctrine_Record
...
@@ -87,35 +121,35 @@ class RecordHookTest extends Doctrine_Record
{
{
$this
->
hasColumn
(
'name'
,
'string'
,
null
,
array
(
'primary'
=>
true
));
$this
->
hasColumn
(
'name'
,
'string'
,
null
,
array
(
'primary'
=>
true
));
}
}
public
function
preSave
()
public
function
preSave
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
postSave
()
public
function
postSave
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
preInsert
()
public
function
preInsert
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
postInsert
()
public
function
postInsert
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
preUpdate
()
public
function
preUpdate
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
postUpdate
()
public
function
postUpdate
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
preDelete
()
public
function
preDelete
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
public
function
postDelete
()
public
function
postDelete
(
$event
)
{
{
$this
->
_messages
[]
=
__FUNCTION__
;
$this
->
_messages
[]
=
__FUNCTION__
;
}
}
...
...
tests/classes.php
View file @
e1fbae22
...
@@ -21,7 +21,7 @@ class Entity extends Doctrine_Record
...
@@ -21,7 +21,7 @@ class Entity extends Doctrine_Record
$this
->
hasColumn
(
'created'
,
'integer'
,
11
);
$this
->
hasColumn
(
'created'
,
'integer'
,
11
);
$this
->
hasColumn
(
'updated'
,
'integer'
,
11
);
$this
->
hasColumn
(
'updated'
,
'integer'
,
11
);
$this
->
hasColumn
(
'email_id'
,
'integer'
);
$this
->
hasColumn
(
'email_id'
,
'integer'
);
$this
->
option
(
'subclasses'
,
array
(
'User'
,
'Group'
));
$this
->
option
(
'subclasses'
,
array
(
'User'
,
'Group'
));
}
}
}
}
class
FieldNameTest
extends
Doctrine_Record
class
FieldNameTest
extends
Doctrine_Record
...
...
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