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

(-)a/C4/Members.pm (-11 / +17 lines)
Lines 1807-1818 sub GetSortDetails { Link Here
1807
  $result = &MoveMemberToDeleted($borrowernumber);
1807
  $result = &MoveMemberToDeleted($borrowernumber);
1808
1808
1809
Copy the record from borrowers to deletedborrowers table.
1809
Copy the record from borrowers to deletedborrowers table.
1810
The routine returns 1 for success, undef for failure.
1810
1811
1811
=cut
1812
=cut
1812
1813
1813
# FIXME: should do it in one SQL statement w/ subquery
1814
# Otherwise, we should return the @data on success
1815
1816
sub MoveMemberToDeleted {
1814
sub MoveMemberToDeleted {
1817
    my ($member) = shift or return;
1815
    my ($member) = shift or return;
1818
    my $dbh = C4::Context->dbh;
1816
    my $dbh = C4::Context->dbh;
Lines 1821-1833 sub MoveMemberToDeleted { Link Here
1821
          WHERE borrowernumber=?|;
1819
          WHERE borrowernumber=?|;
1822
    my $sth = $dbh->prepare($query);
1820
    my $sth = $dbh->prepare($query);
1823
    $sth->execute($member);
1821
    $sth->execute($member);
1824
    my @data = $sth->fetchrow_array;
1822
    my $data = $sth->fetchrow_hashref;
1825
    (@data) or return;  # if we got a bad borrowernumber, there's nothing to insert
1823
    return if !$data;  # probably bad borrowernumber
1826
    $sth =
1824
1827
      $dbh->prepare( "INSERT INTO deletedborrowers VALUES ("
1825
    #now construct a insert query that does not depend on the same order of
1828
          . ( "?," x ( scalar(@data) - 1 ) )
1826
    #columns in borrowers and deletedborrowers (see BZ 13084)
1829
          . "?)" );
1827
    my $insertq = "INSERT INTO deletedborrowers (";
1830
    $sth->execute(@data);
1828
    my @values;
1829
    foreach my $key ( keys %$data ) {
1830
        $insertq.= $key.",";
1831
        push @values, $data->{$key};
1832
    }
1833
    $insertq =~ s/,$//; #remove last comma
1834
    $insertq .= ") VALUES (" . ( "?," x ( scalar(@values) - 1 ) ) . "?)";
1835
    $sth = $dbh->prepare( $insertq );
1836
    $sth->execute(@values);
1837
    return $sth->err? undef: 1;
1831
}
1838
}
1832
1839
1833
=head2 DelMember
1840
=head2 DelMember
1834
- 

Return to bug 13084