|
Lines 695-704
sub GetMemberIssuesAndFines {
Link Here
|
| 695 |
return ($overdue_count, $issue_count, $total_fines); |
695 |
return ($overdue_count, $issue_count, $total_fines); |
| 696 |
} |
696 |
} |
| 697 |
|
697 |
|
| 698 |
sub columns(;$) { |
698 |
|
| 699 |
return @{C4::Context->dbh->selectcol_arrayref("SHOW columns from borrowers")}; |
699 |
=head2 columns |
|
|
700 |
|
| 701 |
C4::Member->columns |
| 702 |
|
| 703 |
=head3 USAGE |
| 704 |
|
| 705 |
use C4::Member; |
| 706 |
my @borrower_columns = C4::Member->columns; |
| 707 |
|
| 708 |
=head3 RETURNS |
| 709 |
|
| 710 |
The array of borrowers' table columns on success. |
| 711 |
An empty array on failure. |
| 712 |
|
| 713 |
=head3 NOTES |
| 714 |
|
| 715 |
This runs significantly faster than the previous code while |
| 716 |
being mostly SQL-agnostic. |
| 717 |
|
| 718 |
=cut |
| 719 |
|
| 720 |
sub columns { |
| 721 |
|
| 722 |
# Check what DB we are using (current only returns mysql) |
| 723 |
my $db=C4::Context->db_scheme2dbi(C4::Context->config("db_scheme")); |
| 724 |
|
| 725 |
# FIXME: Other DB's may require an additional elsif, |
| 726 |
# or revision to the if. :) |
| 727 |
# Not limiting the SQL query causes a drastic drop |
| 728 |
# in speed (~3-4 seconds for ~1 million records |
| 729 |
# compared to <1s with limit 1). |
| 730 |
my $sql; |
| 731 |
if ( 'mysql,' =~ /$db/ ) { |
| 732 |
$sql = 'SELECT * FROM borrowers LIMIT 1;'; |
| 733 |
} |
| 734 |
else { |
| 735 |
$sql = 'SELECT * FROM borrowers;'; |
| 736 |
} |
| 737 |
|
| 738 |
# Get the database handle. |
| 739 |
my $dbh = C4::Context->dbh; |
| 740 |
|
| 741 |
# Run the SQL statement to load STH's readonly properties. |
| 742 |
my $sth = $dbh->prepare($sql); |
| 743 |
my $rv = $sth->execute(); |
| 744 |
|
| 745 |
# This only fails if the table doesn't exist. |
| 746 |
# This will always be called AFTER an install or upgrade, |
| 747 |
# so borrowers will exist! |
| 748 |
my @data; |
| 749 |
if ($sth->{NUM_OF_FIELDS}>0) { |
| 750 |
@data = @{$sth->{NAME}}; |
| 751 |
} |
| 752 |
else { |
| 753 |
@data = (); |
| 754 |
} |
| 755 |
$sth->finish(); |
| 756 |
return @data; |
| 700 |
} |
757 |
} |
| 701 |
|
758 |
|
|
|
759 |
|
| 702 |
=head2 ModMember |
760 |
=head2 ModMember |
| 703 |
|
761 |
|
| 704 |
my $success = ModMember(borrowernumber => $borrowernumber, |
762 |
my $success = ModMember(borrowernumber => $borrowernumber, |