GetBiblionumberFromItemnumber
&GetRecordValue
- &GetFieldMapping
- &SetFieldMapping
- &DeleteFieldMapping
&GetISBDView
=back
-In the 3.0 version of Koha, the authoritative record-level information is in biblioitems.marcxml
+In the 3.0 version of Koha, the authoritative record-level information is in biblio_metadata.metadata
Because the data isn't completely normalized there's a chance for information to get out of sync. The design choice to go with a un-normalized schema was driven by performance and stability concerns. However, if this occur, it can be considered as a bug : The API is (or should be) complete & the only entry point for all biblio/items managements.
return $error if $error;
}
+
# delete biblio from Koha tables and save in deletedbiblio
# must do this *after* _koha_delete_biblioitems, otherwise
# delete cascade will prevent deletedbiblioitems rows
return \@result;
}
-=head2 SetFieldMapping
-
- SetFieldMapping($framework, $field, $fieldcode, $subfieldcode);
-
-Set a Field to MARC mapping value, if it already exists we don't add a new one.
-
-=cut
-
-sub SetFieldMapping {
- my ( $framework, $field, $fieldcode, $subfieldcode ) = @_;
- my $dbh = C4::Context->dbh;
-
- my $sth = $dbh->prepare('SELECT * FROM fieldmapping WHERE fieldcode = ? AND subfieldcode = ? AND frameworkcode = ? AND field = ?');
- $sth->execute( $fieldcode, $subfieldcode, $framework, $field );
- if ( not $sth->fetchrow_hashref ) {
- my @args;
- $sth = $dbh->prepare('INSERT INTO fieldmapping (fieldcode, subfieldcode, frameworkcode, field) VALUES(?,?,?,?)');
-
- $sth->execute( $fieldcode, $subfieldcode, $framework, $field );
- }
-}
-
-=head2 DeleteFieldMapping
-
- DeleteFieldMapping($id);
-
-Delete a field mapping from an $id.
-
-=cut
-
-sub DeleteFieldMapping {
- my ($id) = @_;
- my $dbh = C4::Context->dbh;
-
- my $sth = $dbh->prepare('DELETE FROM fieldmapping WHERE id = ?');
- $sth->execute($id);
-}
-
-=head2 GetFieldMapping
-
- GetFieldMapping($frameworkcode);
-
-Get all field mappings for a specified frameworkcode
-
-=cut
-
-sub GetFieldMapping {
- my ($framework) = @_;
- my $dbh = C4::Context->dbh;
-
- my $sth = $dbh->prepare('SELECT * FROM fieldmapping where frameworkcode = ?');
- $sth->execute($framework);
-
- my @return;
- while ( my $row = $sth->fetchrow_hashref ) {
- push @return, $row;
- }
- return \@return;
-}
-
=head2 GetBiblioData
$data = &GetBiblioData($biblionumber);
my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
+ my $dbh = C4::Context->dbh;
my $query = "
SELECT biblioitemnumber,
publicationyear,
FROM biblioitems
WHERE biblioitemnumber IN ($biblioitemnumber_values)
";
- return get_infos_of( $query, 'biblioitemnumber' );
+ return $dbh->selectall_hashref($query, 'biblioitemnumber');
}
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
my $sth = $dbh->prepare("SELECT * FROM biblio WHERE biblionumber=?");
$sth->execute($biblionumber);
+ # FIXME There is a transaction in _koha_delete_biblio_metadata
+ # But actually all the following should be done inside a single transaction
if ( my $data = $sth->fetchrow_hashref ) {
# save the record in deletedbiblio
$bkup_sth->execute(@bind);
$bkup_sth->finish;
+ _koha_delete_biblio_metadata( $biblionumber );
+
# delete the biblio
my $sth2 = $dbh->prepare("DELETE FROM biblio WHERE biblionumber=?");
$sth2->execute($biblionumber);
return;
}
+=head2 _koha_delete_biblio_metadata
+
+ $error = _koha_delete_biblio_metadata($biblionumber);
+
+C<$biblionumber> - the biblionumber of the biblio metadata to be deleted
+
+=cut
+
+sub _koha_delete_biblio_metadata {
+ my ($biblionumber) = @_;
+
+ my $dbh = C4::Context->dbh;
+ my $schema = Koha::Database->new->schema;
+ $schema->txn_do(
+ sub {
+ $dbh->do( q|
+ INSERT INTO deletedbiblio_metadata (biblionumber, format, marcflavour, metadata)
+ SELECT biblionumber, format, marcflavour, metadata FROM biblio_metadata WHERE biblionumber=?
+ |, undef, $biblionumber );
+ $dbh->do( q|DELETE FROM biblio_metadata WHERE biblionumber=?|,
+ undef, $biblionumber );
+ }
+ );
+}
+
=head1 UNEXPORTED FUNCTIONS
=head2 ModBiblioMarc