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

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

Return to bug 13084