Koha::AdditionalField
use Koha::AdditionalField; my $af1 = Koha::AdditionalField->new({id => $id}); my $af2 = Koha::AuthorisedValue->new({ tablename => 'my_table', name => 'a_name', authorised_value_category => 'LOST', marcfield => '200$a', searchable => 1, }); $av1->delete; $av2->{name} = 'another_name'; $av2->update;
Class for managing additional fields into Koha.
Create a new Koha::AdditionalField object. This method can be called using several ways. Either with the id for existing field or with different values for a new one.
The caller just knows the id of the additional field and want to retrieve all values.
The caller wants to create a new additional field.
The information will be retrieved from the database.
If the AdditionalField object has been modified and the values have to be modified into the database, call this method.
Remove a the record in the database using the id the object.
Insert a new AdditionalField object into the database.
Insert new values for a record.
my $af = Koha::AdditionalField({ id => $id })->fetch; my $af->{values} = { record_id1 => 'my value', record_id2 => 'another value', }; $af->insert_values;
Retrieve values from the database for a given record_id. The record_id argument is optional.
my $af = Koha::AdditionalField({ id => $id })->fetch; my $values = $af->fetch_values({record_id => $record_id}); $values will be equal to something like: { record_id => { field_name1 => 'value1', field_name2 => 'value2', } }
Delete values from the database for a given record_id. The record_id argument is optional.
my $af = Koha::AdditionalField({ id => $id })->fetch; $af->delete_values({record_id => $record_id});
Retrieve all additional fields in the database given some parameters. Parameters are optional. This method returns a list of AdditionalField objects. This is a static method.
my $fields = Koha::AdditionalField->all; or my $fields = Koha::AdditionalField->all{(tablename => 'my_table'}); or my $fields = Koha::AdditionalField->all({searchable => 1});
Retrieve all values for a table name. This is a static method.
my $values = Koha::AdditionalField({ tablename => 'my_table' }); $values will be equel to something like: { record_id1 => { field_name1 => 'value1', field_name2 => 'value2', }, record_id2 => { field_name1 => 'value3', field_name2 => 'value4', } }
Retrieve all record_ids for records matching the field values given in parameter. This method returns a list of ids. This is a static method.
my $fields = [ { name => 'field_name', value => 'field_value', } ]; my $ids = Koha::AdditionalField->get_matching_record_ids( { tablename => 'subscription', fields => $fields } );
Jonathan Druart <jonathan.druart at biblibre.com>
Copyright 2013 BibLibre
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Koha; if not, see <http://www.gnu.org/licenses>.