Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redmine-sync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
redmine-sync
Commits
66c057d2
Commit
66c057d2
authored
8 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
add delete method and reorganized redmine specific methods
parent
9cd91942
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Redmine/DB/MySQL.pm
+78
-49
78 additions, 49 deletions
lib/Redmine/DB/MySQL.pm
with
78 additions
and
49 deletions
lib/Redmine/DB/MySQL.pm
+
78
−
49
View file @
66c057d2
...
...
@@ -11,9 +11,9 @@ use Data::Dumper;
my
$show_query
=
0
;
my
$show_fetched
=
0
;
sub
show_fetched
{
shift
;
$show_fetched
=
shift
;
}
sub
show_query
{
shift
;
$show_query
=
shift
;
}
sub
verbose
{
shift
;
$show_fetched
=
$show_query
=
shift
;
}
sub
show_fetched
{
shift
;
my
$ret
=
$show_fetched
;
$show_fetched
=
shift
;
$ret
;
}
sub
show_query
{
shift
;
my
$ret
=
$show_query
;
$show_query
=
shift
;
$ret
}
sub
verbose
{
shift
;
my
@ret
=
(
$show_fetched
,
$show_query
);
$show_fetched
=
$show_query
=
shift
;
@ret
;
}
sub
connect
{
...
...
@@ -65,9 +65,6 @@ sub get_all_x
my
$dbh
=
$self
->
connect
();
return
undef
unless
(
defined
(
$dbh
));
# my $project= new Redmine::DB::Project (%par);
# print "project: ", Dumper ($project);
my
$ss
=
"
SELECT
$field_ref
FROM
$table
";
my
@v
=
();
...
...
@@ -103,6 +100,38 @@ sub get_all_x
$tt
;
}
sub
delete_all_x
{
my
$self
=
shift
;
my
$table
=
shift
;
my
$where
=
shift
;
my
$field_ref
=
shift
||
'
*
';
my
$dbh
=
$self
->
connect
();
return
undef
unless
(
defined
(
$dbh
));
my
$ss
=
"
DELETE
$field_ref
FROM
$table
";
my
@v
=
();
if
(
defined
(
$where
))
{
# print "where: ", Dumper ($where) if ($show_query);
$ss
.=
'
WHERE
'
.
shift
(
@$where
);
@v
=
@$where
;
}
if
(
$show_query
)
{
print
"
ss=[
$ss
]
";
print
'
vars:
',
join
('
,
',
@v
)
if
(
@v
);
print
"
\n
";
}
my
$sth
=
$dbh
->
prepare
(
$ss
)
or
print
$dbh
->
errstr
;
# print "sth=[$sth]\n";
$sth
->
execute
(
@v
);
}
sub
tables
{
my
$self
=
shift
;
...
...
@@ -186,48 +215,6 @@ sub desc
$td
;
}
# BEGIN Redmine specific part
sub
fetch_custom
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$res
=
$db
->
get_all_x
('
custom_values
',
[
"
custom_field_id=? and customized_type=?
",
$cfid
,
$cfty
]);
$res
;
}
sub
change_custom_value
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$cfref
=
shift
;
# ticket number or whatever
my
$cfrid
=
shift
;
# record id
my
$cfval
=
shift
;
my
$data
=
{
customized_type
=>
$cfty
,
customized_id
=>
$cfref
,
custom_field_id
=>
$cfid
,
value
=>
$cfval
};
print
"
change_custom_value: cfrid=[
$cfrid
]
",
join
('
',
%$data
),
"
\n
";
# return 0; # TODO: add flag to supress changes
my
$res
;
if
(
defined
(
$cfrid
))
{
$db
->
update
('
custom_values
',
$cfrid
,
$data
);
$res
=
$cfrid
;
}
else
{
$res
=
$db
->
insert
('
custom_values
',
$data
);
}
$res
;
}
sub
insert
{
my
$self
=
shift
;
...
...
@@ -297,7 +284,8 @@ sub mysql
my
$self
=
shift
;
print
"
self:
",
Dumper
(
$self
);
my
@cmd
=
('
mysql
',
'
-h
',
$self
->
{'
host
'},
'
-u
',
$self
->
{'
username
'},
$self
->
{'
database
'},
'
--password=
'
.
$self
->
{'
password
'});
$ENV
{
MYSQL_PWD
}
=
$self
->
{
password
};
my
@cmd
=
('
mysql
',
'
-h
',
$self
->
{'
host
'},
'
-u
',
$self
->
{'
username
'},
$self
->
{'
database
'});
print
"
>> cmd=[
",
join
('
',
@cmd
),
"
]
\n
";
system
(
@cmd
);
}
...
...
@@ -467,6 +455,47 @@ sub pcx_user_preferences
$res
;
}
sub
fetch_custom
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$res
=
$db
->
get_all_x
('
custom_values
',
[
"
custom_field_id=? and customized_type=?
",
$cfid
,
$cfty
]);
$res
;
}
sub
change_custom_value
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$cfref
=
shift
;
# ticket number or whatever
my
$cfrid
=
shift
;
# record id
my
$cfval
=
shift
;
my
$data
=
{
customized_type
=>
$cfty
,
customized_id
=>
$cfref
,
custom_field_id
=>
$cfid
,
value
=>
$cfval
};
print
"
change_custom_value: cfrid=[
$cfrid
]
",
join
('
',
%$data
),
"
\n
";
# return 0; # TODO: add flag to supress changes
my
$res
;
if
(
defined
(
$cfrid
))
{
$db
->
update
('
custom_values
',
$cfrid
,
$data
);
$res
=
$cfrid
;
}
else
{
$res
=
$db
->
insert
('
custom_values
',
$data
);
}
$res
;
}
1
;
__END__
...
...
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