Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
synchro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
synchro
Commits
475a53ec
Commit
475a53ec
authored
2 months ago
by
Jean-Philippe Metivier
Browse files
Options
Downloads
Patches
Plain Diff
Ajout du mecanisme permettant à la clef primaire de ne pas devoir s'appeller 'id'
parent
dbec2738
No related branches found
No related tags found
No related merge requests found
Pipeline
#36744
failed
2 months ago
Stage: publish
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenSynchro/Service/SqlHelper/SqlHelperService.php
+6
-11
6 additions, 11 deletions
src/UnicaenSynchro/Service/SqlHelper/SqlHelperService.php
src/UnicaenSynchro/Service/Synchronisation/SynchronisationService.php
+4
-3
4 additions, 3 deletions
...ynchro/Service/Synchronisation/SynchronisationService.php
with
10 additions
and
14 deletions
src/UnicaenSynchro/Service/SqlHelper/SqlHelperService.php
+
6
−
11
View file @
475a53ec
...
@@ -104,8 +104,7 @@ class SqlHelperService
...
@@ -104,8 +104,7 @@ class SqlHelperService
}
}
public
function
update
(
EntityManager
$entityManager
,
string
$table
,
array
$item
,
array
$correspondance
,
string
$primarykey_id
,
string
$id
,
?string
$source
=
null
):
void
public
function
update
(
EntityManager
$entityManager
,
string
$table
,
array
$item
,
array
$correspondance
,
string
$id
,
?string
$source
=
null
):
void
{
{
$values
=
[];
$values
=
[];
foreach
(
$correspondance
as
$s
=>
$d
)
{
foreach
(
$correspondance
as
$s
=>
$d
)
{
...
@@ -113,23 +112,19 @@ class SqlHelperService
...
@@ -113,23 +112,19 @@ class SqlHelperService
}
}
if
(
$source
!==
null
)
$values
[]
=
"source_id='"
.
$source
.
"'"
;
if
(
$source
!==
null
)
$values
[]
=
"source_id='"
.
$source
.
"'"
;
$values
[]
=
"updated_on=now()"
;
$values
[]
=
"updated_on=now()"
;
$sql
=
"update "
.
$table
.
" set "
.
implode
(
" , "
,
$values
)
.
" where
id
=:id"
;
$sql
=
"update "
.
$table
.
" set "
.
implode
(
" , "
,
$values
)
.
" where
"
.
$primarykey_id
.
"
=:id"
;
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
}
}
public
function
restore
(
EntityManager
$entityManager
,
string
$table
,
string
$primarykey_id
,
string
$id
):
void
public
function
restore
(
EntityManager
$entityManager
,
string
$table
,
string
$id
):
void
{
{
$sql
=
"update "
.
$table
.
" set deleted_on=NULL where
id
=:id"
;
$sql
=
"update "
.
$table
.
" set deleted_on=NULL where
"
.
$primarykey_id
.
"
=:id"
;
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
}
}
public
function
delete
(
EntityManager
$entityManager
,
string
$table
,
string
$primarykey_id
,
string
$id
):
void
public
function
delete
(
EntityManager
$entityManager
,
string
$table
,
string
$id
):
void
{
{
$sql
=
"update "
.
$table
.
" set deleted_on=now() where
id
=:id"
;
$sql
=
"update "
.
$table
.
" set deleted_on=now() where
"
.
$primarykey_id
.
"
=:id"
;
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
$this
->
executeRequeteRef
(
$entityManager
,
$sql
,
[
"id"
=>
$id
]);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/UnicaenSynchro/Service/Synchronisation/SynchronisationService.php
+
4
−
3
View file @
475a53ec
...
@@ -144,6 +144,7 @@ class SynchronisationService
...
@@ -144,6 +144,7 @@ class SynchronisationService
$orm_destination
=
$this
->
entityManagers
[
$this
->
getFromConfig
(
$name
,
'orm_destination'
)];
$orm_destination
=
$this
->
entityManagers
[
$this
->
getFromConfig
(
$name
,
'orm_destination'
)];
$table_destination
=
$this
->
getFromConfig
(
$name
,
'table_destination'
);
$table_destination
=
$this
->
getFromConfig
(
$name
,
'table_destination'
);
$source
=
$this
->
getFromConfig
(
$name
,
'source'
);
$source
=
$this
->
getFromConfig
(
$name
,
'source'
);
$primarykey_id
=
$this
->
getFromConfig
(
$name
,
'id'
);
$debut
=
new
DateTime
();
$debut
=
new
DateTime
();
...
@@ -167,7 +168,7 @@ class SynchronisationService
...
@@ -167,7 +168,7 @@ class SynchronisationService
if
(
$item
[
'deleted_on'
]
===
null
&&
!
isset
(
$data_source
[
$id
]))
{
if
(
$item
[
'deleted_on'
]
===
null
&&
!
isset
(
$data_source
[
$id
]))
{
$nbRetrait
++
;
$nbRetrait
++
;
// $texte_retrait .= "Retrait de ".$id." des données destination.\n";
// $texte_retrait .= "Retrait de ".$id." des données destination.\n";
$this
->
getSqlHelperService
()
->
delete
(
$orm_destination
,
$table_destination
,
$id
);
$this
->
getSqlHelperService
()
->
delete
(
$orm_destination
,
$table_destination
,
$primarykey_id
,
$id
);
}
}
}
}
...
@@ -196,7 +197,7 @@ class SynchronisationService
...
@@ -196,7 +197,7 @@ class SynchronisationService
if
(
isset
(
$data_destination
[
$id
])
and
$data_destination
[
$id
][
"deleted_on"
]
!==
null
)
{
if
(
isset
(
$data_destination
[
$id
])
and
$data_destination
[
$id
][
"deleted_on"
]
!==
null
)
{
$nbRestauration
++
;
$nbRestauration
++
;
// $texte_restauration .= "Restauration de ".$id." des données destinations.\n";
// $texte_restauration .= "Restauration de ".$id." des données destinations.\n";
$this
->
getSqlHelperService
()
->
restore
(
$orm_destination
,
$table_destination
,
$id
);
$this
->
getSqlHelperService
()
->
restore
(
$orm_destination
,
$table_destination
,
$primarykey_id
,
$id
);
}
}
}
}
echo
"#Restauration: "
.
$nbRestauration
.
"
\n
"
;
echo
"#Restauration: "
.
$nbRestauration
.
"
\n
"
;
...
@@ -210,7 +211,7 @@ class SynchronisationService
...
@@ -210,7 +211,7 @@ class SynchronisationService
if
(
isset
(
$data_destination
[
$id
])
and
$this
->
checkDifferences
(
$item
,
$data_destination
[
$id
],
$correspondance
,
$source
))
{
if
(
isset
(
$data_destination
[
$id
])
and
$this
->
checkDifferences
(
$item
,
$data_destination
[
$id
],
$correspondance
,
$source
))
{
$nbModification
++
;
$nbModification
++
;
// $texte_modication .= "Modif de ".$id." des données sources.\n";
// $texte_modication .= "Modif de ".$id." des données sources.\n";
$this
->
getSqlHelperService
()
->
update
(
$orm_destination
,
$table_destination
,
$item
,
$correspondance
,
$id
,
$source
);
$this
->
getSqlHelperService
()
->
update
(
$orm_destination
,
$table_destination
,
$item
,
$correspondance
,
$primarykey_id
,
$id
,
$source
);
}
}
}
}
echo
"#Modification: "
.
$nbModification
.
"
\n
"
;
echo
"#Modification: "
.
$nbModification
.
"
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment