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
2643a9fe
Commit
2643a9fe
authored
11 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
valuestore class: php8 only; added variable types; short array syntax
parent
9a0cc4b1
Branches
Branches containing commit
No related tags found
1 merge request
!66
php8 only; added variable types; short array syntax; remove glyphicons
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/valuestore/classes/valuestore.class.php
+272
-216
272 additions, 216 deletions
public_html/valuestore/classes/valuestore.class.php
with
272 additions
and
216 deletions
public_html/valuestore/classes/valuestore.class.php
+
272
−
216
View file @
2643a9fe
...
@@ -26,40 +26,45 @@
...
@@ -26,40 +26,45 @@
* $aVersions=$oVersion->deleteValues("version");
* $aVersions=$oVersion->deleteValues("version");
*
*
* @author hahn
* @author hahn
*
* Axel: <axel.hahn@unibe.ch>
* (...)
* 2024-08-29 Axel php8 only; added variable types; short array syntax
*/
*/
class
valuestore
{
class
valuestore
{
public
$sProject
=
false
;
public
string
$sProject
=
''
;
public
$sPackage
=
false
;
public
string
$sPackage
=
''
;
public
$sPhase
=
false
;
public
string
$sPhase
=
''
;
public
$sPlace
=
false
;
public
string
$sPlace
=
''
;
public
$sHost
=
false
;
public
string
$sHost
=
''
;
public
$sVariable
=
false
;
public
string
$sVariable
=
''
;
public
$sData
=
false
;
public
string
$sData
=
''
;
protected
$_bDebug
=
true
;
protected
bool
$_bDebug
=
true
;
/**
/**
* filename of sqlite database file
* filename of sqlite database file
* @var
type
* @var
string
*/
*/
private
$_dbfile
=
false
;
private
string
$_dbfile
=
''
;
/**
/**
* database connection
* database connection
* @var object
* @var object
*/
*/
protected
$_oDB
=
false
;
protected
object
$_oDB
;
/**
/**
* TTL vor stored values - 1 day [sec]
* TTL vor stored values - 1 day [sec]
* @var integer
* @var integer
*/
*/
protected
$_iTTL
=
86400
;
protected
int
$_iTTL
=
86400
;
/**
/**
* create statement for the database
* create statement for the database
* @var
type
* @var
string
*/
*/
private
$_sCreate
=
'
private
$_sCreate
=
'
CREATE TABLE "values" (
CREATE TABLE "values" (
...
@@ -77,17 +82,18 @@ class valuestore {
...
@@ -77,17 +82,18 @@ class valuestore {
;
;
// hardcoded
// hardcoded
protected
$_allowedPhases
=
array
(
'preview'
,
'stage'
,
'live'
)
;
protected
array
$_allowedPhases
=
[
'preview'
,
'stage'
,
'live'
]
;
protected
$_allowedPlaces
=
array
(
'onhold'
,
'ready2install'
,
'deployed'
)
;
protected
array
$_allowedPlaces
=
[
'onhold'
,
'ready2install'
,
'deployed'
]
;
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// CONSTRUCTOR
// CONSTRUCTOR
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
*
c
onstructor ... no params
*
C
onstructor ... no params
*/
*/
public
function
__construct
(){
public
function
__construct
()
{
// cache dir is hardcoded to versions directory :-/
// cache dir is hardcoded to versions directory :-/
$this
->
_dbfile
=
__DIR__
.
'/../data/versioncache.db'
;
$this
->
_dbfile
=
__DIR__
.
'/../data/versioncache.db'
;
...
@@ -97,14 +103,18 @@ class valuestore {
...
@@ -97,14 +103,18 @@ class valuestore {
$this
->
_createDb
();
$this
->
_createDb
();
}
}
}
}
/**
/**
* add a log messsage
* Add a logging messsage with ahlogger
*
* @global object $oLog
* @global object $oLog
*
* @param string $sMessage messeage text
* @param string $sMessage messeage text
* @param string $sLevel warnlevel of the given message
* @param string $sLevel warnlevel of the given message
* @return bool
* @return bool
*/
*/
private
function
log
(
$sMessage
,
$sLevel
=
"info"
)
{
private
function
log
(
$sMessage
,
$sLevel
=
"info"
):
bool
{
global
$oCLog
;
global
$oCLog
;
if
(
$oCLog
)
{
if
(
$oCLog
)
{
return
$oCLog
->
add
(
basename
(
__FILE__
)
.
" class "
.
__CLASS__
.
" - "
.
$sMessage
,
$sLevel
);
return
$oCLog
->
add
(
basename
(
__FILE__
)
.
" class "
.
__CLASS__
.
" - "
.
$sMessage
,
$sLevel
);
...
@@ -118,8 +128,10 @@ class valuestore {
...
@@ -118,8 +128,10 @@ class valuestore {
/**
/**
* create sqlite database - called in constructor if the file does not exist
* create sqlite database - called in constructor if the file does not exist
* @return boolean
*/
*/
private
function
_createDb
()
{
private
function
_createDb
():
bool
{
if
(
file_exists
(
$this
->
_dbfile
))
{
if
(
file_exists
(
$this
->
_dbfile
))
{
echo
$this
->
_bDebug
?
"removing existing file
$this->_dbfile
...<br>
\n
"
:
''
;
echo
$this
->
_bDebug
?
"removing existing file
$this->_dbfile
...<br>
\n
"
:
''
;
unlink
(
$this
->
_dbfile
);
unlink
(
$this
->
_dbfile
);
...
@@ -135,12 +147,16 @@ class valuestore {
...
@@ -135,12 +147,16 @@ class valuestore {
}
}
/**
/**
* execute a sql statement
* Execute a sql statement
* It returns false if the query failed.
* On success you get a PDO result object
*
* @param string $sSql sql statement
* @param string $sSql sql statement
* @param array $aVars array with values (uses PDO::prepare(); $sSql must contain placeholders :key)
* @param array $aVars array with values (uses PDO::prepare(); $sSql must contain placeholders :key)
* @return
database object
* @return
bool|object result object of query
*/
*/
private
function
_makeQuery
(
$sSql
,
$aVars
=
false
)
{
private
function
_makeQuery
(
string
$sSql
,
array
$aVars
=
[]):
bool
|
object
{
// $this->_log(__FUNCTION__."($sSql)");
// $this->_log(__FUNCTION__."($sSql)");
// echo "DEBUG: executing SQL<pre>$sSql</pre>";
// echo "DEBUG: executing SQL<pre>$sSql</pre>";
$this
->
log
(
"start query"
);
$this
->
log
(
"start query"
);
...
@@ -158,20 +174,23 @@ class valuestore {
...
@@ -158,20 +174,23 @@ class valuestore {
}
}
/**
/**
* execute a sql statement
* Execute a sql SELECT statement and get an array with results
*
* @param string $sSql sql statement
* @param string $sSql sql statement
* @param string $sKey optional: return only values of this key
* @return array of resultset
* @return array of resultset
*/
*/
private
function
_makeSelectQuery
(
$sSql
,
$aKey
=
false
)
{
private
function
_makeSelectQuery
(
string
$sSql
,
string
$sKey
=
''
):
array
{
// $this->_log(__FUNCTION__."($sSql)");
// $this->_log(__FUNCTION__."($sSql)");
// echo "DEBUG: executing select SQL<pre>$sSql</pre>";
// echo "DEBUG: executing select SQL<pre>$sSql</pre>";
$this
->
log
(
"start query"
);
$this
->
log
(
"start query"
);
$oStatement
=
$this
->
_oDB
->
prepare
(
$sSql
);
$oStatement
=
$this
->
_oDB
->
prepare
(
$sSql
);
$oStatement
->
execute
();
$oStatement
->
execute
();
$aReturn
=
array
()
;
$aReturn
=
[]
;
while
(
$row
=
$oStatement
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
while
(
$row
=
$oStatement
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
if
(
$
a
Key
&&
array_key_exists
(
$
a
Key
,
$row
)){
if
(
$
s
Key
&&
array_key_exists
(
$
s
Key
,
$row
))
{
$aReturn
[]
=
$row
[
$
a
Key
];
$aReturn
[]
=
$row
[
$
s
Key
];
}
else
{
}
else
{
$aReturn
[]
=
$row
;
$aReturn
[]
=
$row
;
}
}
...
@@ -181,13 +200,15 @@ class valuestore {
...
@@ -181,13 +200,15 @@ class valuestore {
}
}
/**
/**
*
l
og error and quit. it echoes the error message on screen if debug
*
L
og error and quit. it echoes the error message on screen if debug
* is enabled.
* is enabled.
*
* @param string $sFunction name of method that throws the error
* @param string $sFunction name of method that throws the error
* @param string $sMessage error message
* @param string $sMessage error message
* @return
boolean
* @return
void
*/
*/
private
function
_quit
(
$sFunction
,
$sMessage
){
private
function
_quit
(
string
$sFunction
,
string
$sMessage
):
void
{
error_log
(
__CLASS__
.
"::
$sFunction
-
$sMessage
"
.
"whereiam: "
.
print_r
(
$this
->
whereiam
(),
1
));
error_log
(
__CLASS__
.
"::
$sFunction
-
$sMessage
"
.
"whereiam: "
.
print_r
(
$this
->
whereiam
(),
1
));
if
(
$this
->
_bDebug
)
{
if
(
$this
->
_bDebug
)
{
echo
__CLASS__
.
"::
$sFunction
stopped.<br>
\n
"
echo
__CLASS__
.
"::
$sFunction
stopped.<br>
\n
"
...
@@ -197,7 +218,6 @@ class valuestore {
...
@@ -197,7 +218,6 @@ class valuestore {
}
else
{
}
else
{
die
(
"ERROR ... wrong usage of class "
.
__CLASS__
);
die
(
"ERROR ... wrong usage of class "
.
__CLASS__
);
}
}
return
false
;
}
}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
...
@@ -206,28 +226,31 @@ class valuestore {
...
@@ -206,28 +226,31 @@ class valuestore {
/**
/**
*
g
et list of current projects
*
G
et list of current projects
* @return
type
* @return
array
*/
*/
public
function
getProjects
(){
public
function
getProjects
():
array
{
$sSql
=
"select distinct(project) from `values`"
;
$sSql
=
"select distinct(project) from `values`"
;
return
$this
->
_makeSelectQuery
(
$sSql
,
'project'
);
return
$this
->
_makeSelectQuery
(
$sSql
,
'project'
);
}
}
/**
/**
*
g
et list of current projects
*
G
et list of current projects
* @return
type
* @return
array
*/
*/
public
function
getPackages
(){
public
function
getPackages
():
array
{
$sSql
=
"select distinct(package) from `values`"
;
$sSql
=
"select distinct(package) from `values`"
;
return
$this
->
_makeSelectQuery
(
$sSql
,
'package'
);
return
$this
->
_makeSelectQuery
(
$sSql
,
'package'
);
}
}
/**
/**
*
g
et phases of the current project; a project must be set be set before
*
G
et phases of the current project; a project must be set be set before
* @return
type
* @return
array
*/
*/
public
function
getPhases
(){
public
function
getPhases
():
array
{
if
(
!
$this
->
sProject
&&
!
$this
->
sPackage
)
{
if
(
!
$this
->
sProject
&&
!
$this
->
sPackage
)
{
$this
->
_quit
(
__FUNCTION__
,
"you need to set a project first. Use the setProject() method to do so."
);
$this
->
_quit
(
__FUNCTION__
,
"you need to set a project first. Use the setProject() method to do so."
);
}
}
...
@@ -262,9 +285,10 @@ class valuestore {
...
@@ -262,9 +285,10 @@ class valuestore {
/**
/**
* get hosts that have installed a project
* get hosts that have installed a project
* @return
type
* @return
array
*/
*/
public
function
getHosts
(){
public
function
getHosts
():
array
{
$sWhere
=
'1=1 '
$sWhere
=
'1=1 '
.
(
$this
->
sProject
?
"AND project='"
.
$this
->
sProject
.
"' "
:
""
)
.
(
$this
->
sProject
?
"AND project='"
.
$this
->
sProject
.
"' "
:
""
)
.
(
$this
->
sPackage
?
"AND package='"
.
$this
->
sPackage
.
"' "
:
""
)
.
(
$this
->
sPackage
?
"AND package='"
.
$this
->
sPackage
.
"' "
:
""
)
...
@@ -277,13 +301,16 @@ class valuestore {
...
@@ -277,13 +301,16 @@ class valuestore {
}
}
/**
/**
*
g
et entries of the current place (project, phase and place can be
*
G
et entries of the current place (project, phase and place can be
* set before)
* set before)
*
* @see setProject()
* @see setProject()
*
* @param string $sVariable variable for filtering column "variable"
* @param string $sVariable variable for filtering column "variable"
* @return array
* @return array
*/
*/
public
function
getVar
(
$sVariable
=
''
){
public
function
getVar
(
$sVariable
=
''
):
array
{
$sWhere
=
'1=1 '
$sWhere
=
'1=1 '
.
(
$this
->
sProject
?
"AND project='"
.
$this
->
sProject
.
"' "
:
""
)
.
(
$this
->
sProject
?
"AND project='"
.
$this
->
sProject
.
"' "
:
""
)
.
(
$this
->
sPackage
?
"AND package='"
.
$this
->
sPackage
.
"' "
:
""
)
.
(
$this
->
sPackage
?
"AND package='"
.
$this
->
sPackage
.
"' "
:
""
)
...
@@ -297,12 +324,15 @@ class valuestore {
...
@@ -297,12 +324,15 @@ class valuestore {
}
}
/**
/**
*
g
et versions of the current place (project, phase and place can be
*
G
et versions of the current place (project, phase and place can be
* set before)
* set before)
*
* @see setProject()
* @see setProject()
*
* @return array
* @return array
*/
*/
public
function
getVersion
(){
public
function
getVersion
():
array
{
$aData
=
$this
->
getVar
(
'version'
);
$aData
=
$this
->
getVar
(
'version'
);
// get json in subkey host -> data and store keys in host -> _data
// get json in subkey host -> data and store keys in host -> _data
...
@@ -316,23 +346,26 @@ class valuestore {
...
@@ -316,23 +346,26 @@ class valuestore {
}
}
/**
/**
*
r
et
urn
curre
b
ntly set project, phase, place and host
*
G
et currently set project, phase, place and host
* @return array
* @return array
*/
*/
public
function
whereiam
(){
public
function
whereiam
():
array
return
array
(
{
return
[
'project'
=>
$this
->
sProject
,
'project'
=>
$this
->
sProject
,
'package'
=>
$this
->
sPackage
,
'package'
=>
$this
->
sPackage
,
'phase'
=>
$this
->
sPhase
,
'phase'
=>
$this
->
sPhase
,
'place'
=>
$this
->
sPlace
,
'place'
=>
$this
->
sPlace
,
'host'
=>
$this
->
sHost
,
'host'
=>
$this
->
sHost
,
)
;
]
;
}
}
/**
/**
*
r
et
urn currebntly set project, phase, place and host
*
G
et
all values in valuestore as array
* @return
type
* @return
array
*/
*/
public
function
dumpdb
(){
public
function
dumpdb
():
array
{
$sSql
=
"select * from `values`"
;
$sSql
=
"select * from `values`"
;
return
$this
->
_makeSelectQuery
(
$sSql
);
return
$this
->
_makeSelectQuery
(
$sSql
);
}
}
...
@@ -343,47 +376,50 @@ class valuestore {
...
@@ -343,47 +376,50 @@ class valuestore {
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
*
i
nit a "position" before getting or updating deleting a value
*
I
nit a "position" before getting or updating deleting a value
*
*
* @param string $sProject project id
* @param string $sProject project id
* @param string $sPackage package id
* @param string $sPackage package id
* @param string $sPhase phase (preview|stage|live)
* @param string $sPhase
optional:
phase (preview|stage|live)
* @param string $sPlace place (onhold|ready2install|deployed)
* @param string $sPlace
optional:
place (onhold|ready2install|deployed)
* @param string $sHost hostname (for place deployed)
* @param string $sHost
optional:
hostname (for place deployed)
* @return
type
string
* @return string
*/
*/
public
function
setProject
(
$sProject
,
$sPackage
,
$sPhase
=
false
,
$sPlace
=
false
,
$sHost
=
false
){
public
function
setProject
(
string
$sProject
,
string
$sPackage
,
string
$sPhase
=
''
,
string
$sPlace
=
''
,
$sHost
=
''
):
string
{
$this
->
sProject
=
preg_replace
(
'/[^a-z\-\_0-9]/'
,
''
,
$sProject
);
$this
->
sProject
=
preg_replace
(
'/[^a-z\-\_0-9]/'
,
''
,
$sProject
);
$this
->
setPackage
(
$sPackage
,
$sPhase
,
$sPlace
,
$sHost
);
$this
->
setPackage
(
$sPackage
,
$sPhase
,
$sPlace
,
$sHost
);
return
$this
->
sProject
;
return
$this
->
sProject
;
}
}
/**
/**
*
s
et a package (and more granular items)
*
S
et a package (and more granular items)
* @see setProject()
* @see setProject()
*
*
* @param string $sPackage package id
* @param string $sPackage package id
* @param string $sPhase phase (preview|stage|live)
* @param string $sPhase phase (preview|stage|live)
* @param string $sPlace place (onhold|ready2install|deployed)
* @param string $sPlace
optional:
place (onhold|ready2install|deployed)
* @param string $sHost hostname (for place deployed)
* @param string $sHost
optional:
hostname (for place deployed)
* @return
type
string
* @return string
*/
*/
public
function
setPackage
(
$sPackage
,
$sPhase
,
$sPlace
=
false
,
$sHost
=
false
){
public
function
setPackage
(
string
$sPackage
,
string
$sPhase
,
string
$sPlace
=
''
,
string
$sHost
=
''
):
string
{
$this
->
sPackage
=
preg_replace
(
'/[^a-z\-\_0-9]/'
,
''
,
$sPackage
);
$this
->
sPackage
=
preg_replace
(
'/[^a-z\-\_0-9]/'
,
''
,
$sPackage
);
$this
->
setPhase
(
$sPhase
,
$sPlace
,
$sHost
);
$this
->
setPhase
(
$sPhase
,
$sPlace
,
$sHost
);
return
$this
->
sPackage
;
return
$this
->
sPackage
;
}
}
/**
/**
*
s
et a phase (and more granular items)
*
S
et a phase (and more granular items)
* @see setProject()
* @see setProject()
*
*
* @param string $sPhase phase (preview|stage|live)
* @param string $sPhase phase (preview|stage|live)
* @param string $sPlace place (onhold|ready2install|deployed)
* @param string $sPlace
optional:
place (onhold|ready2install|deployed)
* @param string $sHost hostname (for place deployed)
* @param string $sHost
optional:
hostname (for place deployed)
* @return type string
* @return type string
*/
*/
public
function
setPhase
(
$sPhase
,
$sPlace
=
false
,
$sHost
=
false
){
public
function
setPhase
(
string
$sPhase
,
string
$sPlace
=
''
,
string
$sHost
=
''
):
string
{
if
(
!
$this
->
sProject
&&
!
$this
->
sPackage
)
{
if
(
!
$this
->
sProject
&&
!
$this
->
sPackage
)
{
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project. Use the setProject() method to do so."
);
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project. Use the setProject() method to do so."
);
return
false
;
return
false
;
...
@@ -397,14 +433,17 @@ class valuestore {
...
@@ -397,14 +433,17 @@ class valuestore {
}
}
/**
/**
* set a place (and host)
* Set a place (and optional a host)
* It aborts if project and package are not set
*
* @see setProject()
* @see setProject()
*
*
* @param string $sPlace place (onhold|ready2install|deployed)
* @param string $sPlace place (onhold|ready2install|deployed)
* @param string $sHost hostname (for place deployed)
* @param string $sHost
optional:
hostname (for place deployed)
* @return
type string
* @return
bool
*/
*/
public
function
setPlace
(
$sPlace
,
$sHost
=
false
){
public
function
setPlace
(
$sPlace
,
string
$sHost
=
''
):
bool
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
))
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
))
{
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project and phase. Use the setProject() method to do so."
);
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project and phase. Use the setProject() method to do so."
);
return
false
;
return
false
;
...
@@ -417,17 +456,20 @@ class valuestore {
...
@@ -417,17 +456,20 @@ class valuestore {
}
}
$this
->
sPlace
=
$sPlace
;
$this
->
sPlace
=
$sPlace
;
$this
->
setHost
(
$sHost
);
$this
->
setHost
(
$sHost
);
return
$this
->
sPlac
e
;
return
tru
e
;
}
}
/**
/**
* set a host for place "deployed"
* Set a host for place "deployed".
* It aborts if project and package are not set
*
* @see setProject()
* @see setProject()
*
*
* @param string $sHost hostname
* @param string $sHost hostname
* @return
type string
* @return
bool
*/
*/
public
function
setHost
(
$sHost
=
false
){
public
function
setHost
(
$sHost
=
''
):
bool
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
))
{
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."
);
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. Use the setProject() method to do so."
);
return
false
;
return
false
;
...
@@ -441,7 +483,7 @@ class valuestore {
...
@@ -441,7 +483,7 @@ class valuestore {
}
}
*/
*/
$this
->
sHost
=
preg_replace
(
'/[^a-z\.\-0-9]/'
,
''
,
$sHost
);
$this
->
sHost
=
preg_replace
(
'/[^a-z\.\-0-9]/'
,
''
,
$sHost
);
return
$this
->
sHost
;
return
true
;
}
}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
...
@@ -449,12 +491,15 @@ class valuestore {
...
@@ -449,12 +491,15 @@ class valuestore {
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
* cleanup value store
* Cleanup value store: delete entries older a given ttl value in seconds
* Afterwards a "vacuum" command will be started.
*
* @param integer $iTtl optional: max age in seconds of items to keep; 0 to delete all; default is 1 day
* @param integer $iTtl optional: max age in seconds of items to keep; 0 to delete all; default is 1 day
* @return boolean
* @return boolean
*/
*/
public
function
cleanup
(
$iTtl
=
false
){
public
function
cleanup
(
int
$iTtl
=
-
1
):
bool
if
(
$iTtl
===
false
){
{
if
(
$iTtl
===
-
1
)
{
$iTtl
=
$this
->
_iTTL
;
$iTtl
=
$this
->
_iTTL
;
}
}
$sTtlDate
=
date
(
"Y-m-d H:i:s"
,
date
(
"U"
)
-
(
int
)
$iTtl
);
$sTtlDate
=
date
(
"Y-m-d H:i:s"
,
date
(
"U"
)
-
(
int
)
$iTtl
);
...
@@ -472,13 +517,18 @@ class valuestore {
...
@@ -472,13 +517,18 @@ class valuestore {
}
}
/**
/**
*
d
elete values from value store. You need to call setProject() to set
*
D
elete values from value store. You need to call setProject() to set
* project or package and optional phase, place, host. Then call this delete
* project or package and optional phase, place, host. Then call this delete
* method.
* method.
* It returns a PDO result object.
* It aborts if project and package are not set
* It returns false on database query error
*
* @param string $sVariable optional: limit deletion to a given variable
* @param string $sVariable optional: limit deletion to a given variable
* @return boolean
* @return boolean
|object
*/
*/
public
function
deleteValues
(
$sVariable
){
public
function
deleteValues
(
$sVariable
):
bool
|
object
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
))
{
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."
);
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. use the setProject() method to do so."
);
}
}
...
@@ -497,10 +547,15 @@ class valuestore {
...
@@ -497,10 +547,15 @@ class valuestore {
}
}
/**
/**
* update a version
* Update a version informatio in value store.
* @return boolean
* It returns a PDO result object.
* It aborts if project and package are not set
* It returns false on database query error
*
* @return boolean|object
*/
*/
public
function
updateVar
(
$sVarname
,
$sValue
){
public
function
updateVar
(
$sVarname
,
$sValue
):
bool
|
object
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)
||
!
$this
->
sPhase
||
!
$this
->
sPlace
)
{
if
((
!
$this
->
sProject
&&
!
$this
->
sPackage
)
||
!
$this
->
sPhase
||
!
$this
->
sPlace
)
{
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. use the setProject() method to do so."
);
$this
->
_quit
(
__FUNCTION__
,
"ERROR: you need to set a project, phase and place. use the setProject() method to do so."
);
}
}
...
@@ -521,10 +576,10 @@ class valuestore {
...
@@ -521,10 +576,10 @@ class valuestore {
"
;
"
;
return
$this
->
_makeQuery
(
return
$this
->
_makeQuery
(
$sSql
,
$sSql
,
array
(
[
'variable'
=>
$sVarname
,
'variable'
=>
$sVarname
,
'value'
=>
$sValue
,
'value'
=>
$sValue
,
)
]
);
);
}
}
/**
/**
...
@@ -532,7 +587,8 @@ class valuestore {
...
@@ -532,7 +587,8 @@ class valuestore {
* @param type $sVersioninfos
* @param type $sVersioninfos
* @return boolean
* @return boolean
*/
*/
public
function
updateVersion
(
$sVersioninfos
){
public
function
updateVersion
(
$sVersioninfos
)
{
return
$this
->
updateVar
(
'version'
,
$sVersioninfos
);
return
$this
->
updateVar
(
'version'
,
$sVersioninfos
);
}
}
...
...
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