@@ -, +, @@ --- C4/Items.pm | 47 +++++------------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -35,6 +35,7 @@ use DateTime::Format::MySQL; use Data::Dumper; # used as part of logging item record changes, not just for # debugging; so please don't remove this use Koha::DateUtils qw/dt_from_string/; +use Koha::Database; use Koha::Database; @@ -3069,27 +3070,8 @@ and an empty array on failure. =cut sub columns { - # Pure ANSI SQL goodness. - my $sql = 'SELECT * FROM items WHERE 1=0;'; - - # Get the database handle. - my $dbh = C4::Context->dbh; - - # Run the SQL statement to load STH's readonly properties. - my $sth = $dbh->prepare($sql); - my $rv = $sth->execute(); - - # This only fails if the table doesn't exist. - # This will always be called AFTER an install or upgrade, - # so borrowers will exist! - my @data; - if ($sth->{NUM_OF_FIELDS}>0) { - @data = @{$sth->{NAME}}; - } - else { - @data = (); - } - return @data; + my $rs = Koha::Database->new->schema->resultset('Item'); + return $rs->result_source->columns; } =head2 biblioitems_columns @@ -3102,27 +3084,8 @@ and an empty array on failure. =cut sub biblioitems_columns { - # Pure ANSI SQL goodness. - my $sql = 'SELECT * FROM biblioitems WHERE 1=0;'; - - # Get the database handle. - my $dbh = C4::Context->dbh; - - # Run the SQL statement to load STH's readonly properties. - my $sth = $dbh->prepare($sql); - my $rv = $sth->execute(); - - # This only fails if the table doesn't exist. - # This will always be called AFTER an install or upgrade, - # so borrowers will exist! - my @data; - if ($sth->{NUM_OF_FIELDS}>0) { - @data = @{$sth->{NAME}}; - } - else { - @data = (); - } - return @data; + my $rs = Koha::Database->new->schema->resultset('Biblioitem'); + return $rs->result_source->columns; } sub ToggleNewStatus { --