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

(-)a/C4/Items.pm (-43 / +5 lines)
Lines 35-40 use DateTime::Format::MySQL; Link Here
35
use Data::Dumper; # used as part of logging item record changes, not just for
35
use Data::Dumper; # used as part of logging item record changes, not just for
36
                  # debugging; so please don't remove this
36
                  # debugging; so please don't remove this
37
use Koha::DateUtils qw/dt_from_string/;
37
use Koha::DateUtils qw/dt_from_string/;
38
use Koha::Database;
38
39
39
use vars qw($VERSION @ISA @EXPORT);
40
use vars qw($VERSION @ISA @EXPORT);
40
41
Lines 2885-2911 and an empty array on failure. Link Here
2885
=cut
2886
=cut
2886
2887
2887
sub columns {
2888
sub columns {
2888
    # Pure ANSI SQL goodness.
2889
    my $rs = Koha::Database->new->schema->resultset('Item');
2889
    my $sql = 'SELECT * FROM items WHERE 1=0;';
2890
    return $rs->result_source->columns;
2890
2891
    # Get the database handle.
2892
    my $dbh = C4::Context->dbh;
2893
2894
    # Run the SQL statement to load STH's readonly properties.
2895
    my $sth = $dbh->prepare($sql);
2896
    my $rv = $sth->execute();
2897
2898
    # This only fails if the table doesn't exist.
2899
    # This will always be called AFTER an install or upgrade,
2900
    # so borrowers will exist!
2901
    my @data;
2902
    if ($sth->{NUM_OF_FIELDS}>0) {
2903
        @data = @{$sth->{NAME}};
2904
    }
2905
    else {
2906
        @data = ();
2907
    }
2908
    return @data;
2909
}
2891
}
2910
2892
2911
=head2 biblioitems_columns
2893
=head2 biblioitems_columns
Lines 2918-2944 and an empty array on failure. Link Here
2918
=cut
2900
=cut
2919
2901
2920
sub biblioitems_columns {
2902
sub biblioitems_columns {
2921
    # Pure ANSI SQL goodness.
2903
    my $rs = Koha::Database->new->schema->resultset('Biblioitem');
2922
    my $sql = 'SELECT * FROM biblioitems WHERE 1=0;';
2904
    return $rs->result_source->columns;
2923
2924
    # Get the database handle.
2925
    my $dbh = C4::Context->dbh;
2926
2927
    # Run the SQL statement to load STH's readonly properties.
2928
    my $sth = $dbh->prepare($sql);
2929
    my $rv = $sth->execute();
2930
2931
    # This only fails if the table doesn't exist.
2932
    # This will always be called AFTER an install or upgrade,
2933
    # so borrowers will exist!
2934
    my @data;
2935
    if ($sth->{NUM_OF_FIELDS}>0) {
2936
        @data = @{$sth->{NAME}};
2937
    }
2938
    else {
2939
        @data = ();
2940
    }
2941
    return @data;
2942
}
2905
}
2943
2906
2944
sub ToggleNewStatus {
2907
sub ToggleNewStatus {
2945
- 

Return to bug 11023