Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 03457b5b

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 03457b5be4b3c0c62dbbb23bb682205669ea65d4
  • Vorgänger 8f7283f5
  • Nachfolger 157c1239

Perl-Upgrade-Scripte: db_query nun auch mit Bind-Parametern

Unterschiede anzeigen:

SL/DBUpgrade2/Base.pm
41 41
}
42 42

  
43 43
sub db_query {
44
  my ($self, $query, $may_fail) = @_;
44
  my ($self, $query, %params) = @_;
45 45

  
46
  return if $self->dbh->do($query);
46
  return if $self->dbh->do($query, undef, @{ $params{bind} || [] });
47 47

  
48
  $self->db_error($query) unless $may_fail;
48
  $self->db_error($query) unless $params{may_fail};
49 49

  
50 50
  $self->dbh->rollback;
51 51
  $self->dbh->begin_work;
......
204 204

  
205 205
Outputs an error message C<$message> to the user and aborts execution.
206 206

  
207
=item C<db_query $query, $may_fail>
207
=item C<db_query $query, %params>
208 208

  
209
Executes an SQL query. What the method does if the query fails depends
210
on C<$may_fail>. If it is falsish then the method will simply die
211
outputting the error message via L</db_error>. If C<$may_fail> is
212
trueish then the current transaction will be rolled back, a new one
213
will be started
209
Executes an SQL query. The following parameters are supported:
210

  
211
=over 2
212

  
213
=item C<may_fail>
214

  
215
What the method does if the query fails depends on this parameter. If
216
it is falsish (the default) then the method will simply die outputting
217
the error message via L</db_error>. If C<may_fail> is trueish then the
218
current transaction will be rolled back, a new one will be started.
219

  
220
=item C<bind>
221

  
222
An optional array reference containing bind parameter for the query.
223

  
224
=back
214 225

  
215 226
=item C<execute_script>
216 227

  

Auch abrufbar als: Unified diff