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 2883-2909 and an empty array on failure. Link Here
2883
=cut
2884
=cut
2884
2885
2885
sub columns {
2886
sub columns {
2886
    # Pure ANSI SQL goodness.
2887
    my $rs = Koha::Database->new->schema->resultset('Item');
2887
    my $sql = 'SELECT * FROM items WHERE 1=0;';
2888
    return $rs->result_source->columns;
2888
2889
    # Get the database handle.
2890
    my $dbh = C4::Context->dbh;
2891
2892
    # Run the SQL statement to load STH's readonly properties.
2893
    my $sth = $dbh->prepare($sql);
2894
    my $rv = $sth->execute();
2895
2896
    # This only fails if the table doesn't exist.
2897
    # This will always be called AFTER an install or upgrade,
2898
    # so borrowers will exist!
2899
    my @data;
2900
    if ($sth->{NUM_OF_FIELDS}>0) {
2901
        @data = @{$sth->{NAME}};
2902
    }
2903
    else {
2904
        @data = ();
2905
    }
2906
    return @data;
2907
}
2889
}
2908
2890
2909
=head2 biblioitems_columns
2891
=head2 biblioitems_columns
Lines 2916-2942 and an empty array on failure. Link Here
2916
=cut
2898
=cut
2917
2899
2918
sub biblioitems_columns {
2900
sub biblioitems_columns {
2919
    # Pure ANSI SQL goodness.
2901
    my $rs = Koha::Database->new->schema->resultset('Biblioitem');
2920
    my $sql = 'SELECT * FROM biblioitems WHERE 1=0;';
2902
    return $rs->result_source->columns;
2921
2922
    # Get the database handle.
2923
    my $dbh = C4::Context->dbh;
2924
2925
    # Run the SQL statement to load STH's readonly properties.
2926
    my $sth = $dbh->prepare($sql);
2927
    my $rv = $sth->execute();
2928
2929
    # This only fails if the table doesn't exist.
2930
    # This will always be called AFTER an install or upgrade,
2931
    # so borrowers will exist!
2932
    my @data;
2933
    if ($sth->{NUM_OF_FIELDS}>0) {
2934
        @data = @{$sth->{NAME}};
2935
    }
2936
    else {
2937
        @data = ();
2938
    }
2939
    return @data;
2940
}
2903
}
2941
2904
2942
sub ToggleNewStatus {
2905
sub ToggleNewStatus {
2943
- 

Return to bug 11023