my @params;
my $selection;
if (defined $owner) {
- @params = ($owner, $mincategory, $row_count);
+ @params = ($owner, $mincategory);
$selection = ' WHERE owner = ? AND category = ?';
} else {
- @params = ( $mincategory, $row_count);
+ @params = ( $mincategory);
$selection = ' WHERE category >= ? ';
}
my $query = 'SELECT * FROM virtualshelves';
$query .= $selection;
- $query .= ' ORDER BY lastmodified DESC LIMIT ?';
+ $query .= ' ORDER BY lastmodified DESC';
+ if ($row_count){
+ $query .= ' LIMIT ?';
+ push @params,$row_count;
+ }
my $sth = $dbh->prepare($query);
$sth->execute(@params);
my $shelflist = $sth->fetchall_arrayref({});
=head2 GetAllShelves
- ($shelflist) = GetAllShelves($owner)
+ $shelflist = GetAllShelves($owner)
-This function returns a references to an array of hashrefs containing all shelves sorted
+This function returns a reference to an array of hashrefs containing all shelves sorted
by the shelf name.
This function is intended to return a dataset reflecting all the shelves for
=cut
-sub GetAllShelves ($$) {
+sub GetAllShelves {
my ($category,$owner) = @_;
- my (@shelflist);
- my @params = ($category,$owner);
- my $query = "SELECT * FROM virtualshelves WHERE category = ? AND owner = ? ORDER BY shelfname ASC";
- my $sth = $dbh->prepare($query);
- $sth->execute(@params);
- @shelflist = $sth->fetchall_arrayref({});
- return ( \@shelflist );
+ my $query = 'SELECT * FROM virtualshelves WHERE category = ? AND owner = ? ORDER BY shelfname ASC';
+ my $sth = $dbh->prepare( $query );
+ $sth->execute( $category, $owner );
+ return $sth->fetchall_arrayref({});
}
=head2 GetShelf
}
my $query =
" SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
- biblio.*, biblioitems.itemtype, biblioitems.publicationyear, biblioitems.publishercode, biblioitems.place, biblioitems.size, biblioitems.pages
+ biblio.*, biblioitems.itemtype, biblioitems.publicationyear as year, biblioitems.publishercode, biblioitems.place, biblioitems.size, biblioitems.pages
FROM virtualshelfcontents vc
LEFT JOIN biblio ON vc.biblionumber = biblio.biblionumber
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber