Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
0093e734
Commit
0093e734
authored
8 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
deployment gui - valuestore - delete method
parent
9cf69207
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/valuestore/classes/valuestore.class.php
+69
-20
69 additions, 20 deletions
public_html/valuestore/classes/valuestore.class.php
public_html/valuestore/index.php
+11
-1
11 additions, 1 deletion
public_html/valuestore/index.php
with
80 additions
and
21 deletions
public_html/valuestore/classes/valuestore.class.php
+
69
−
20
View file @
0093e734
...
...
@@ -14,6 +14,17 @@
* $oVersion->setProject("", $$sPackage, $sPhase, $sPlace);
* $oVersion->updateVar($sVarname, $sValue)
*
* delete
* $oVersion = new valuestore();
*
* to delete values for a single place:
* $oVersion->setProject("", $this->_aPrjConfig["fileprefix"]$sPhase, $sPlace);
* $aVersions=$oVersion->deleteValues();
*
* to delete all version items for a whole whole project (packages) in all phases
* $oVersion->setProject("", $this->_aPrjConfig["fileprefix"]);
* $aVersions=$oVersion->deleteValues("version");
*
* @author hahn
*/
class
valuestore
{
...
...
@@ -326,21 +337,6 @@ class valuestore {
// PUBLIC SETTER
// ----------------------------------------------------------------------
/**
* cleanup value store
* @return boolean
*/
public
function
cleanup
(){
if
(
!
$this
->
_iTTL
){
return
false
;
}
$sTtlDate
=
date
(
"Y-m-d H:i:s"
,
date
(
"U"
)
-
$this
->
_iTTL
);
$sSql
=
"DELETE FROM `values` WHERE `time` < '
$sTtlDate
'"
;
$this
->
_makeQuery
(
$sSql
);
$this
->
_makeQuery
(
"vaccum;"
);
return
true
;
}
/**
* init before setting or getting
* @param string $sProject project id
...
...
@@ -367,7 +363,7 @@ class valuestore {
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project. Use the setProject() method to do so."
);
return
false
;
}
if
(
array_search
(
$sPhase
,
$this
->
_allowedPhases
)
===
false
){
if
(
$sPhase
&&
array_search
(
$sPhase
,
$this
->
_allowedPhases
)
===
false
){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you set a wrong phase [
$sPhase
]"
);
}
$this
->
sPhase
=
$sPhase
;
...
...
@@ -376,11 +372,14 @@ class valuestore {
}
public
function
setPlace
(
$sPlace
,
$sHost
=
false
){
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)
||
!
$this
->
sPhase
){
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project and phase. Use the setProject() method to do so."
);
return
false
;
}
if
(
array_search
(
$sPlace
,
$this
->
_allowedPlaces
)
===
false
){
if
(
$sPlace
&&
!
$this
->
sPhase
){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you cannot set place [
$sPlace
] with leaving phase empty."
);
}
if
(
$sPlace
&&
array_search
(
$sPlace
,
$this
->
_allowedPlaces
)
===
false
){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you set a wrong place [
$sPlace
]"
);
}
$this
->
sPlace
=
$sPlace
;
...
...
@@ -389,7 +388,7 @@ class valuestore {
}
public
function
setHost
(
$sHost
=
false
){
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)
||
!
$this
->
sPhase
||
!
$this
->
sPlace
){
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. Use the setProject() method to do so."
);
return
false
;
}
...
...
@@ -405,6 +404,55 @@ class valuestore {
return
$this
->
sHost
;
}
// ----------------------------------------------------------------------
// DATABASE FUNCTIONS
// ----------------------------------------------------------------------
/**
* cleanup value store
* @return boolean
*/
public
function
cleanup
(){
if
(
!
$this
->
_iTTL
){
return
false
;
}
$sTtlDate
=
date
(
"Y-m-d H:i:s"
,
date
(
"U"
)
-
$this
->
_iTTL
);
$sSql
=
"DELETE FROM `values` WHERE `time` < '
$sTtlDate
'"
;
$this
->
_makeQuery
(
$sSql
);
$this
->
_makeQuery
(
"vaccum;"
);
return
true
;
}
/**
* delete values
* @return boolean
*/
/**
* delete values from value store. You need to call setProject() to set
* project or package and optional phase, place, host. Then call this delete
* method.
* @param string $sVariable optional: limit deletion to a given variable
* @return boolean
*/
public
function
deleteValues
(
$sVariable
){
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)
){
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. use the setProject() method to do so."
);
}
$sWhere
=
'1=1 '
.
(
$this
->
sProject
?
"AND project='"
.
$this
->
sProject
.
"' "
:
""
)
.
(
$this
->
sPackage
?
"AND package='"
.
$this
->
sPackage
.
"' "
:
""
)
.
(
$this
->
sPhase
?
"AND phase='"
.
$this
->
sPhase
.
"' "
:
""
)
.
(
$this
->
sPlace
?
"AND place='"
.
$this
->
sPlace
.
"' "
:
""
)
.
(
$this
->
sHost
?
"AND host='"
.
$this
->
sHost
.
"' "
:
""
)
.
(
$sVariable
?
"AND variable='"
.
$sVariable
.
"' "
:
""
)
;
$sSql
=
"DELETE FROM `values` WHERE
$sWhere
"
;
echo
$sSql
;
// return true;
return
$this
->
_makeQuery
(
$sSql
);
}
/**
* update a version
* @return boolean
...
...
@@ -437,7 +485,8 @@ class valuestore {
);
}
/**
* update a version
* update a version value
* @param type $sVersioninfos
* @return boolean
*/
public
function
updateVersion
(
$sVersioninfos
){
...
...
This diff is collapsed.
Click to expand it.
public_html/valuestore/index.php
+
11
−
1
View file @
0093e734
...
...
@@ -88,7 +88,7 @@ foreach (array("action") as $sKey) {
$sAction
=
getParam
(
'action'
,
'/[^a-z]/'
);
if
(
$sAction
!==
"get"
&&
$sAction
!==
"update"
)
{
if
(
$sAction
!==
"delete"
&&
$sAction
!==
"get"
&&
$sAction
!==
"update"
)
{
quit
(
"action is unknown or not implemented yet."
);
}
...
...
@@ -116,6 +116,16 @@ $oVersion = new valuestore();
$oVersion
->
setProject
(
$sProject
,
$sPackage
,
$sPhase
,
$sPlace
,
$sHost
);
switch
(
$sAction
)
{
case
'delete'
:
if
(
$oVersion
->
deleteValues
(
$sVarname
)){
echo
"OK: "
.
print_r
(
$oVersion
->
whereiam
())
.
" (
$sVarname
) was deleted."
;
}
else
{
echo
"ERROR: update for
$sVarname
failed."
;
}
break
;
break
;
case
'get'
:
header
(
'Content-Type: application/json'
);
echo
json_encode
(
$oVersion
->
getVersion
());
...
...
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