Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 39be0a81

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID 39be0a81ce0dc13b46d01935b57aceacb69416f2
  • Vorgänger 64a301e5
  • Nachfolger 040aa711

TODO: single-dbh

Unterschiede anzeigen:

SL/TODO.pm
3 3
package TODO;
4 4

  
5 5
use SL::DBUtils;
6
use SL::DB;
6 7

  
7 8
use strict;
8 9

  
......
59 60
  my $myconfig = \%main::myconfig;
60 61
  my $form     = $main::form;
61 62

  
62
  my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
63

  
64
  my $query    = qq|SELECT id FROM employee WHERE login = ?|;
63
  SL::DB->client->with_transaction(sub {
64
    my $dbh      = $params{dbh} || SL::DB->client->dbh;
65 65

  
66
  my ($id)     = selectfirst_array_query($form, $dbh, $query, $params{login});
66
    my $query    = qq|SELECT id FROM employee WHERE login = ?|;
67 67

  
68
  if (!$id) {
69
    $main::lxdebug->leave_sub();
70
    return;
71
  }
68
    my ($id)     = selectfirst_array_query($form, $dbh, $query, $params{login});
72 69

  
73
  $query =
74
    qq|SELECT show_after_login
75
       FROM todo_user_config
76
       WHERE employee_id = ?|;
70
    if (!$id) {
71
      $main::lxdebug->leave_sub();
72
      return;
73
    }
77 74

  
78
  if (! selectfirst_hashref_query($form, $dbh, $query, $id)) {
79
    do_query($form, $dbh, qq|INSERT INTO todo_user_config (employee_id) VALUES (?)|, $id);
80
  }
75
    $query =
76
      qq|SELECT show_after_login
77
         FROM todo_user_config
78
         WHERE employee_id = ?|;
81 79

  
82
  $query =
83
    qq|UPDATE todo_user_config SET
84
         show_after_login = ?,
85
         show_follow_ups = ?,
86
         show_follow_ups_login = ?,
87
         show_overdue_sales_quotations = ?,
88
         show_overdue_sales_quotations_login = ?
80
    if (! selectfirst_hashref_query($form, $dbh, $query, $id)) {
81
      do_query($form, $dbh, qq|INSERT INTO todo_user_config (employee_id) VALUES (?)|, $id);
82
    }
89 83

  
90
       WHERE employee_id = ?|;
84
    $query =
85
      qq|UPDATE todo_user_config SET
86
           show_after_login = ?,
87
           show_follow_ups = ?,
88
           show_follow_ups_login = ?,
89
           show_overdue_sales_quotations = ?,
90
           show_overdue_sales_quotations_login = ?
91 91

  
92
  my @values = map { $params{$_} ? 't' : 'f' } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login);
93
  push @values, $id;
92
         WHERE employee_id = ?|;
94 93

  
95
  do_query($form, $dbh, $query, @values);
94
    my @values = map { $params{$_} ? 't' : 'f' } qw(show_after_login show_follow_ups show_follow_ups_login show_overdue_sales_quotations show_overdue_sales_quotations_login);
95
    push @values, $id;
96 96

  
97
  $dbh->commit();
97
    do_query($form, $dbh, $query, @values);
98
  });
98 99

  
99 100
  $main::lxdebug->leave_sub();
100 101
}

Auch abrufbar als: Unified diff