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
84acea5d
Commit
84acea5d
authored
Mar 02, 2007
by
gyim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed saving records using multiple connections
parent
7d5d2179
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
18 deletions
+33
-18
Collection.php
lib/Doctrine/Collection.php
+2
-2
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+6
-6
Record.php
lib/Doctrine/Record.php
+1
-1
Association.php
lib/Doctrine/Relation/Association.php
+9
-4
ForeignKey.php
lib/Doctrine/Relation/ForeignKey.php
+8
-3
LocalKey.php
lib/Doctrine/Relation/LocalKey.php
+7
-2
No files found.
lib/Doctrine/Collection.php
View file @
84acea5d
...
...
@@ -720,7 +720,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$conn
->
beginTransaction
();
foreach
(
$this
as
$key
=>
$record
)
{
$record
->
save
();
$record
->
save
(
$conn
);
};
$conn
->
commit
();
...
...
@@ -741,7 +741,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$conn
->
beginTransaction
();
foreach
(
$this
as
$key
=>
$record
)
{
$record
->
delete
();
$record
->
delete
(
$conn
);
}
$conn
->
commit
();
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
84acea5d
...
...
@@ -151,19 +151,19 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
if
(
!
$record
->
exists
())
{
$saveLater
[
$k
]
=
$fk
;
}
else
{
$v
->
save
();
$v
->
save
(
$this
->
conn
);
}
}
else
{
// ONE-TO-ONE relationship
$obj
=
$record
->
get
(
$fk
->
getAlias
());
if
(
$obj
->
state
()
!=
Doctrine_Record
::
STATE_TCLEAN
)
{
$obj
->
save
();
$obj
->
save
(
$this
->
conn
);
}
}
}
elseif
(
$fk
instanceof
Doctrine_Relation_Association
)
{
$v
->
save
();
$v
->
save
(
$this
->
conn
);
}
}
return
$saveLater
;
...
...
@@ -189,7 +189,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
$table
=
$rel
->
getTable
();
$alias
=
$rel
->
getAlias
();
$rel
->
processDiff
(
$record
);
$rel
->
processDiff
(
$record
,
$this
->
conn
);
}
}
/**
...
...
@@ -206,7 +206,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$obj
=
$record
->
get
(
$fk
->
getAlias
());
$obj
->
delete
();
$obj
->
delete
(
$this
->
conn
);
break
;
};
}
...
...
@@ -264,7 +264,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
switch
(
$value
->
state
())
{
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$record
->
save
();
$record
->
save
(
$this
->
conn
);
default
:
$array
[
$name
]
=
$value
->
getIncremented
();
$record
->
set
(
$name
,
$value
->
getIncremented
());
...
...
lib/Doctrine/Record.php
View file @
84acea5d
...
...
@@ -956,7 +956,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
isset
(
$this
->
references
[
$alias
]))
{
$obj
=
$this
->
references
[
$alias
];
$obj
->
save
();
$obj
->
save
(
$conn
);
}
}
...
...
lib/Doctrine/Relation/Association.php
View file @
84acea5d
...
...
@@ -45,10 +45,15 @@ class Doctrine_Relation_Association extends Doctrine_Relation
/**
* processDiff
*
* @param Doctrine_Record
* @param Doctrine_Record $record
* @param Doctrine_Connection $conn
*/
public
function
processDiff
(
Doctrine_Record
$record
)
public
function
processDiff
(
Doctrine_Record
$record
,
$conn
=
null
)
{
if
(
!
$conn
)
{
$conn
=
$this
->
getTable
()
->
getConnection
();
}
$asf
=
$this
->
getAssociationFactory
();
$alias
=
$this
->
getAlias
();
...
...
@@ -65,7 +70,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
.
' WHERE '
.
$this
->
getForeign
()
.
' = ?'
.
' AND '
.
$this
->
getLocal
()
.
' = ?'
;
$
this
->
getTable
()
->
getConnection
()
->
execute
(
$query
,
array
(
$r
->
getIncremented
(),
$record
->
getIncremented
()));
$
conn
->
execute
(
$query
,
array
(
$r
->
getIncremented
(),
$record
->
getIncremented
()));
}
$operations
=
Doctrine_Relation
::
getInsertOperations
(
$record
->
obtainOriginals
(
$alias
),
$new
);
...
...
@@ -74,7 +79,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
$reldao
=
$asf
->
create
();
$reldao
->
set
(
$this
->
getForeign
(),
$r
);
$reldao
->
set
(
$this
->
getLocal
(),
$record
);
$reldao
->
save
();
$reldao
->
save
(
$conn
);
}
$record
->
assignOriginals
(
$alias
,
clone
$record
->
get
(
$alias
));
...
...
lib/Doctrine/Relation/ForeignKey.php
View file @
84acea5d
...
...
@@ -37,17 +37,22 @@ class Doctrine_Relation_ForeignKey extends Doctrine_Relation
* processDiff
*
* @param Doctrine_Record $record
* @param Doctrine_Connection $conn
* @return void
*/
public
function
processDiff
(
Doctrine_Record
$record
)
public
function
processDiff
(
Doctrine_Record
$record
,
$conn
=
null
)
{
if
(
!
$conn
)
{
$conn
=
$this
->
getTable
()
->
getConnection
();
}
$alias
=
$this
->
getAlias
();
if
(
$this
->
isOneToOne
())
{
if
(
$record
->
obtainOriginals
(
$alias
)
&&
$record
->
obtainOriginals
(
$alias
)
->
obtainIdentifier
()
!=
$this
->
obtainReference
(
$alias
)
->
obtainIdentifier
()
)
{
$record
->
obtainOriginals
(
$alias
)
->
delete
();
$record
->
obtainOriginals
(
$alias
)
->
delete
(
$conn
);
}
}
else
{
if
(
$record
->
hasReference
(
$alias
))
{
...
...
@@ -59,7 +64,7 @@ class Doctrine_Relation_ForeignKey extends Doctrine_Relation
$operations
=
Doctrine_Relation
::
getDeleteOperations
(
$record
->
obtainOriginals
(
$alias
),
$new
);
foreach
(
$operations
as
$r
)
{
$r
->
delete
();
$r
->
delete
(
$conn
);
}
$record
->
assignOriginals
(
$alias
,
clone
$record
->
get
(
$alias
));
...
...
lib/Doctrine/Relation/LocalKey.php
View file @
84acea5d
...
...
@@ -37,15 +37,20 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
* processDiff
*
* @param Doctrine_Record $record
* @param Doctrine_Connection $conn
*/
public
function
processDiff
(
Doctrine_Record
$record
)
public
function
processDiff
(
Doctrine_Record
$record
,
$conn
=
null
)
{
if
(
!
$conn
)
{
$conn
=
$this
->
getTable
()
->
getConnection
();
}
$alias
=
$this
->
getAlias
();
if
(
$record
->
obtainOriginals
(
$alias
)
&&
$record
->
obtainOriginals
(
$alias
)
->
obtainIdentifier
()
!=
$this
->
references
[
$alias
]
->
obtainIdentifier
()
)
{
$record
->
obtainOriginals
(
$alias
)
->
delete
();
$record
->
obtainOriginals
(
$alias
)
->
delete
(
$conn
);
}
}
/**
...
...
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