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
7e003d3a
Commit
7e003d3a
authored
May 22, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transactions now register collections for snapshots
parent
124fbff0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
Collection.php
lib/Doctrine/Collection.php
+6
-10
Transaction.php
lib/Doctrine/Transaction.php
+19
-0
No files found.
lib/Doctrine/Collection.php
View file @
7e003d3a
...
@@ -154,8 +154,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -154,8 +154,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$this
->
_table
=
$connection
->
getTable
(
$this
->
_table
);
$this
->
_table
=
$connection
->
getTable
(
$this
->
_table
);
$this
->
expanded
=
array
();
$this
->
expandable
=
true
;
$name
=
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
$name
=
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
if
(
$name
!==
null
)
{
if
(
$name
!==
null
)
{
...
@@ -263,12 +261,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -263,12 +261,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
*/
public
function
remove
(
$key
)
public
function
remove
(
$key
)
{
{
if
(
!
isset
(
$this
->
data
[
$key
]))
{
$this
->
expand
(
$key
);
throw
new
Doctrine_Collection_Exception
(
'Unknown key '
.
$key
);
}
$removed
=
$this
->
data
[
$key
];
$removed
=
$this
->
data
[
$key
];
unset
(
$this
->
data
[
$key
]);
unset
(
$this
->
data
[
$key
]);
...
@@ -366,6 +358,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -366,6 +358,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
isset
(
$this
->
referenceField
))
{
if
(
isset
(
$this
->
referenceField
))
{
$record
->
set
(
$this
->
referenceField
,
$this
->
reference
,
false
);
$record
->
set
(
$this
->
referenceField
,
$this
->
reference
,
false
);
}
}
$this
->
data
[
$key
]
=
$record
;
$this
->
data
[
$key
]
=
$record
;
}
}
/**
/**
...
@@ -426,7 +419,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -426,7 +419,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
$value
!==
null
)
{
if
(
$value
!==
null
)
{
$list
[]
=
$value
;
$list
[]
=
$value
;
}
}
}
;
}
$query
->
from
(
$this
->
_table
->
getComponentName
()
.
'('
.
implode
(
", "
,
$this
->
_table
->
getPrimaryKeys
())
.
')'
);
$query
->
from
(
$this
->
_table
->
getComponentName
()
.
'('
.
implode
(
", "
,
$this
->
_table
->
getPrimaryKeys
())
.
')'
);
$query
->
where
(
$this
->
_table
->
getComponentName
()
.
'.id IN ('
.
substr
(
str_repeat
(
"?, "
,
count
(
$list
)),
0
,
-
2
)
.
')'
);
$query
->
where
(
$this
->
_table
->
getComponentName
()
.
'.id IN ('
.
substr
(
str_repeat
(
"?, "
,
count
(
$list
)),
0
,
-
2
)
.
')'
);
...
@@ -584,6 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -584,6 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* saves all records of this collection and processes the
* saves all records of this collection and processes the
* difference of the last snapshot and the current data
* difference of the last snapshot and the current data
*
*
* @param Doctrine_Connection $conn optional connection parameter
* @return Doctrine_Collection
* @return Doctrine_Collection
*/
*/
public
function
save
(
Doctrine_Connection
$conn
=
null
)
public
function
save
(
Doctrine_Connection
$conn
=
null
)
...
@@ -592,10 +586,11 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -592,10 +586,11 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$conn
=
$this
->
_table
->
getConnection
();
$conn
=
$this
->
_table
->
getConnection
();
}
}
$conn
->
beginTransaction
();
$conn
->
beginTransaction
();
$conn
->
transaction
->
addCollection
(
$this
);
$this
->
processDiff
();
$this
->
processDiff
();
foreach
(
$this
as
$key
=>
$record
)
{
foreach
(
$this
->
getData
()
as
$key
=>
$record
)
{
$record
->
save
(
$conn
);
$record
->
save
(
$conn
);
}
}
...
@@ -618,6 +613,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -618,6 +613,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
}
$conn
->
beginTransaction
();
$conn
->
beginTransaction
();
$conn
->
transaction
->
addCollection
(
$this
);
foreach
(
$this
as
$key
=>
$record
)
{
foreach
(
$this
as
$key
=>
$record
)
{
$record
->
delete
(
$conn
);
$record
->
delete
(
$conn
);
...
...
lib/Doctrine/Transaction.php
View file @
7e003d3a
...
@@ -63,6 +63,19 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -63,6 +63,19 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
* @var array $savepoints an array containing all savepoints
* @var array $savepoints an array containing all savepoints
*/
*/
protected
$savePoints
=
array
();
protected
$savePoints
=
array
();
/**
* @var array $_collections an array of Doctrine_Collection objects that were affected during the Transaction
*/
protected
$_collections
=
array
();
/**
* addCollection
*
* @param Doctrine_Collection $coll
*/
public
function
addCollection
(
Doctrine_Collection
$coll
)
{
$this
->
_collections
[]
=
$coll
;
}
/**
/**
* getState
* getState
* returns the state of this connection
* returns the state of this connection
...
@@ -253,6 +266,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
...
@@ -253,6 +266,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
throw
new
Doctrine_Validator_Exception
(
$tmp
);
throw
new
Doctrine_Validator_Exception
(
$tmp
);
}
}
// take snapshots of all collections used within this transaction
foreach
(
array_unique
(
$this
->
_collections
)
as
$coll
)
{
$coll
->
takeSnapshot
();
}
$this
->
_collections
=
array
();
$this
->
conn
->
getDbh
()
->
commit
();
$this
->
conn
->
getDbh
()
->
commit
();
//$this->conn->unitOfWork->reset();
//$this->conn->unitOfWork->reset();
...
...
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