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
6c12f689
Commit
6c12f689
authored
8 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
versions class: queries can use PDO prepare method; update names of places (like in project.class)
parent
5fb0676c
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/versions/classes/versions.class.php
+24
-12
24 additions, 12 deletions
public_html/versions/classes/versions.class.php
public_html/versions/index.php
+6
-4
6 additions, 4 deletions
public_html/versions/index.php
with
30 additions
and
16 deletions
public_html/versions/classes/versions.class.php
+
24
−
12
View file @
6c12f689
...
@@ -77,13 +77,19 @@ class versions {
...
@@ -77,13 +77,19 @@ class versions {
/**
/**
* execute a sql statement
* execute a sql statement
* @param string $sSql sql statement
* @param string $sSql sql statement
* @param array $aVars array with values (uses PDO::prepare(); $sSql must contain placeholders :key)
* @return database object
* @return database object
*/
*/
private
function
_makeQuery
(
$sSql
)
{
private
function
_makeQuery
(
$sSql
,
$aVars
=
false
)
{
// $this->_log(__FUNCTION__."($sSql)");
// $this->_log(__FUNCTION__."($sSql)");
// echo "DEBUG: executing SQL<pre>$sSql</pre>";
// echo "DEBUG: executing SQL<pre>$sSql</pre>";
$oDb
=
new
PDO
(
"sqlite:"
.
$this
->
_dbfile
);
$oDb
=
new
PDO
(
"sqlite:"
.
$this
->
_dbfile
);
if
(
$aVars
&&
is_array
(
$aVars
)){
$sth
=
$oDb
->
prepare
(
$sSql
);
$result
=
$sth
->
execute
(
$aVars
);
}
else
{
$result
=
$oDb
->
query
(
$sSql
);
$result
=
$oDb
->
query
(
$sSql
);
}
return
$result
;
return
$result
;
}
}
...
@@ -168,7 +174,7 @@ class versions {
...
@@ -168,7 +174,7 @@ class versions {
WHERE
WHERE
project='"
.
$this
->
sProject
.
"'
project='"
.
$this
->
sProject
.
"'
AND phase='"
.
$this
->
sPhase
.
"'
AND phase='"
.
$this
->
sPhase
.
"'
AND place='
install
ed'
AND place='
deploy
ed'
"
;
"
;
return
$this
->
_makeSelectQuery
(
$sSql
,
'host'
);
return
$this
->
_makeSelectQuery
(
$sSql
,
'host'
);
}
}
...
@@ -241,7 +247,7 @@ class versions {
...
@@ -241,7 +247,7 @@ class versions {
die
(
"ERROR: you need to set a project and phase. Use the setProject() method to do so."
);
die
(
"ERROR: you need to set a project and phase. Use the setProject() method to do so."
);
return
false
;
return
false
;
}
}
if
(
$sPlace
!==
'
queue
'
&&
$sPlace
!==
'
puppet
'
&&
$sPlace
!==
'
install
ed'
){
if
(
$sPlace
!==
'
onhold
'
&&
$sPlace
!==
'
ready2install
'
&&
$sPlace
!==
'
deploy
ed'
){
die
(
"ERROR: you set a wrong place [
$sPlace
]"
);
die
(
"ERROR: you set a wrong place [
$sPlace
]"
);
}
}
$this
->
sPlace
=
$sPlace
;
$this
->
sPlace
=
$sPlace
;
...
@@ -254,11 +260,11 @@ class versions {
...
@@ -254,11 +260,11 @@ class versions {
die
(
"ERROR: you need to set a project, phase and place. Use the setProject() method to do so."
);
die
(
"ERROR: you need to set a project, phase and place. Use the setProject() method to do so."
);
return
false
;
return
false
;
}
}
if
(
$sHost
&&
$this
->
sPlace
!==
'
install
ed'
){
if
(
$sHost
&&
$this
->
sPlace
!==
'
deploy
ed'
){
die
(
"ERROR: a host can be set on place [
install
ed] only."
);
die
(
"ERROR: a host can be set on place [
deploy
ed] only."
);
}
}
if
(
!
$sHost
&&
$this
->
sPlace
===
'
install
ed'
){
if
(
!
$sHost
&&
$this
->
sPlace
===
'
deploy
ed'
){
die
(
"ERROR: on place [
install
ed] a host MUST be set."
);
die
(
"ERROR: on place [
deploy
ed] a host MUST be set."
);
}
}
$this
->
sHost
=
$sHost
;
$this
->
sHost
=
$sHost
;
return
$this
->
sHost
;
return
$this
->
sHost
;
...
@@ -282,11 +288,17 @@ class versions {
...
@@ -282,11 +288,17 @@ class versions {
'"
.
$this
->
sPhase
.
"',
'"
.
$this
->
sPhase
.
"',
'"
.
$this
->
sPlace
.
"',
'"
.
$this
->
sPlace
.
"',
'"
.
$this
->
sHost
.
"',
'"
.
$this
->
sHost
.
"',
'"
.
$sVarname
.
"'
,
:variable
,
'"
.
$sValue
.
"'
:value
);
);
"
;
"
;
return
$this
->
_makeQuery
(
$sSql
);
return
$this
->
_makeQuery
(
$sSql
,
array
(
'variable'
=>
$sVarname
,
'value'
=>
$sValue
,
)
);
}
}
/**
/**
* update a version
* update a version
...
...
This diff is collapsed.
Click to expand it.
public_html/versions/index.php
+
6
−
4
View file @
6c12f689
...
@@ -92,7 +92,7 @@ $sPlace = getParam('place', '/[^a-z]/');
...
@@ -92,7 +92,7 @@ $sPlace = getParam('place', '/[^a-z]/');
$sHost
=
getParam
(
'host'
,
'/[^a-z\.\-0-9]/'
);
$sHost
=
getParam
(
'host'
,
'/[^a-z\.\-0-9]/'
);
if
(
$sHost
&&
!
$sPlace
)
{
if
(
$sHost
&&
!
$sPlace
)
{
$sPlace
=
'
install
ed'
;
$sPlace
=
'
deploy
ed'
;
}
}
$sVarname
=
getParam
(
'variable'
,
'/[^a-z]/'
);
$sVarname
=
getParam
(
'variable'
,
'/[^a-z]/'
);
...
@@ -112,7 +112,6 @@ switch ($sAction) {
...
@@ -112,7 +112,6 @@ switch ($sAction) {
case
'get'
:
case
'get'
:
print_r
(
$oVersion
->
getVersion
());
print_r
(
$oVersion
->
getVersion
());
break
;
break
;
case
'update'
:
case
'update'
:
if
(
!
$sVarname
)
{
if
(
!
$sVarname
)
{
...
@@ -121,8 +120,11 @@ switch ($sAction) {
...
@@ -121,8 +120,11 @@ switch ($sAction) {
switch
(
$sVarname
)
{
switch
(
$sVarname
)
{
// case 'other-varname':
// case 'other-varname':
case
'version'
:
case
'version'
:
$oVersion
->
updateVar
(
$sVarname
,
$sValue
)
;
if
(
$oVersion
->
updateVar
(
$sVarname
,
$sValue
)
){
echo
"OK:
$sVarname
was updated."
;
echo
"OK:
$sVarname
was updated."
;
}
else
{
echo
"ERROR: update for
$sVarname
failed."
;
}
break
;
break
;
default
:
default
:
...
...
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