# Now we build the query in pieces:
# We always select the bre fields:
- my $select = 'select ' . join(',', @breFields);
+ my $select = 'select distinct ' . join(',', @breFields);
# We always use the bre table.
my $from = "from $breTable";
my $self = shift;
my $output;
- my @data = $self->{sth}->fetchrow_array;
- if (@data) {
- my $bre = $self->{breClass}->new(\@data);
+ my $data = $self->{sth}->fetchrow_hashref;
+ if ($data) {
+ my $bre = $self->{breClass}->from_bare_hash($data);
if ($Marque::config->option_value('format') eq 'BRE') {
$output = OpenSRF::Utils::JSON->perl2JSON($bre);
} else {
($location ? ('a' => $location) : ()),
b => $acp->call_number()->owning_lib()->shortname(),
b => $acp->circ_lib()->shortname(),
- c => $acp->copy_location()->name(),
+ c => $acp->location()->name(),
j => $acp->call_number()->label(),
($acp->circ_modifier() ? (g => $acp->circ_modifier()) : ()),
p => $acp->barcode(),
$query .= "\nfrom $classTable";
my $sth = $self->{handle}->prepare($query);
if ($sth->execute()) {
- my $result = $sth->fetchall_arrayref();
- my @orgs = map {$fmClass->new($_)} @{$result};
+ my $result = $sth->fetchall_arrayref({});
+ my @orgs = map {$fmClass->from_bare_hash($_)} @{$result};
$self->{orgs} = \@orgs;
} else {
$self->{orgs} = [];
my $classTable = $fmClass->Table();
my $query = 'select ' . join(',', @classFields);
$query .= "\nfrom $classTable";
- my $result = $self->{handle}->selectall_arrayref($query);
- my @shelves = map {$fmClass->new($_)} @{$result};
+ my $result = $self->{handle}->selectall_arrayref($query, {Slice=>{}});
+ my @shelves = map {$fmClass->from_bare_hash($_)} @{$result};
$self->{shelves} = \@shelves;
}
}
if ($self->{acnHandle}->execute($bre)) {
- my $result = $self->{acnHandle}->fetchall_arrayref();
- return map {$self->{acnClass}->new($_)} @{$result};
+ my $result = $self->{acnHandle}->fetchall_arrayref({});
+ return map {$self->{acnClass}->from_bare_hash($_)} @{$result};
}
# If for some reason, we don't find anything.
$query .= "\nwhere deleted = 'f' and call_number in (";
$query .= join(',', map {$_->id()} @acns);
$query .= ")";
- my $result = $self->{handle}->selectall_arrayref($query);
+ my $result = $self->{handle}->selectall_arrayref($query, {Slice=>{}});
if ($result && @{$result}) {
- my @acps = map {$self->{acpClass}->new($_)} @{$result};
- return map {
+ my @acps = map {$self->{acpClass}->from_bare_hash($_)} @{$result};
+ foreach (@acps) {
my $cn = $_->call_number();
my $clib = $_->circ_lib();
- my $loc = $_->copy_loaction();
+ my $loc = $_->location();
my ($org) = grep {$_->id() == $clib} @orgs;
my ($acn) = grep {$_->id() == $cn} @acns;
my ($location) = grep {$_->id() == $loc} @locations;
$acn->owning_lib($owner);
$_->call_number($acn);
$_->circ_lib($org);
- $_->copy_location($location);
- } @acps;
+ $_->location($location);
+ }
+ return @acps;
}
}
sub next {
my $self = shift;
my $output;
- my @data = $self->{sth}->fetchrow_array;
+ my $data = $self->{sth}->fetchrow_hashref;
- if (@data) {
+ if ($data) {
my $format = $Marque::config->option_value('format');
- my $are = $self->{fmClass}->new(\@data);
+ my $are = $self->{fmClass}->from_bare_hash($data);
if ($format eq 'ARE') {
$output = OpenSRF::Utils::JSON->perl2JSON($are);
} else {