View | Details | Raw Unified | Return to bug 13084
Collapse All | Expand All

(-)a/C4/Members.pm (-11 / +17 lines)
Lines 1774-1785 sub GetSortDetails { Link Here
1774
  $result = &MoveMemberToDeleted($borrowernumber);
1774
  $result = &MoveMemberToDeleted($borrowernumber);
1775
1775
1776
Copy the record from borrowers to deletedborrowers table.
1776
Copy the record from borrowers to deletedborrowers table.
1777
The routine returns 1 for success, undef for failure.
1777
1778
1778
=cut
1779
=cut
1779
1780
1780
# FIXME: should do it in one SQL statement w/ subquery
1781
# Otherwise, we should return the @data on success
1782
1783
sub MoveMemberToDeleted {
1781
sub MoveMemberToDeleted {
1784
    my ($member) = shift or return;
1782
    my ($member) = shift or return;
1785
    my $dbh = C4::Context->dbh;
1783
    my $dbh = C4::Context->dbh;
Lines 1788-1800 sub MoveMemberToDeleted { Link Here
1788
          WHERE borrowernumber=?|;
1786
          WHERE borrowernumber=?|;
1789
    my $sth = $dbh->prepare($query);
1787
    my $sth = $dbh->prepare($query);
1790
    $sth->execute($member);
1788
    $sth->execute($member);
1791
    my @data = $sth->fetchrow_array;
1789
    my $data = $sth->fetchrow_hashref;
1792
    (@data) or return;  # if we got a bad borrowernumber, there's nothing to insert
1790
    return if !$data;  # probably bad borrowernumber
1793
    $sth =
1791
1794
      $dbh->prepare( "INSERT INTO deletedborrowers VALUES ("
1792
    #now construct a insert query that does not depend on the same order of
1795
          . ( "?," x ( scalar(@data) - 1 ) )
1793
    #columns in borrowers and deletedborrowers (see BZ 13084)
1796
          . "?)" );
1794
    my $insertq = "INSERT INTO deletedborrowers (";
1797
    $sth->execute(@data);
1795
    my @values;
1796
    foreach my $key ( keys %$data ) {
1797
        $insertq.= $key.",";
1798
        push @values, $data->{$key};
1799
    }
1800
    $insertq =~ s/,$//; #remove last comma
1801
    $insertq .= ") VALUES (" . ( "?," x ( scalar(@values) - 1 ) ) . "?)";
1802
    $sth = $dbh->prepare( $insertq );
1803
    $sth->execute(@values);
1804
    return $sth->err? undef: 1;
1798
}
1805
}
1799
1806
1800
=head2 DelMember
1807
=head2 DelMember
1801
- 

Return to bug 13084