|
Line 0
Link Here
|
|
|
1 |
package Koha::DB::Branchrelation; |
| 2 |
|
| 3 |
use Modern::Perl; |
| 4 |
use C4::Context; #FIXME = create a Koha package for KOHA_CONF reading |
| 5 |
|
| 6 |
use Koha::Schema; |
| 7 |
|
| 8 |
use Moose; |
| 9 |
|
| 10 |
has 'branchcode' => (is => 'rw', required => 0, isa => 'Str'); |
| 11 |
has 'categorycode' => (is => 'rw', required => 0, isa => 'Str'); |
| 12 |
|
| 13 |
|
| 14 |
my $schema = Koha::Schema->connect( |
| 15 |
'dbi:mysql:dbname='.C4::Context->config("database"), |
| 16 |
C4::Context->config("user"), |
| 17 |
C4::Context->config("pass"), |
| 18 |
{ AutoCommit => 1 }, |
| 19 |
); |
| 20 |
|
| 21 |
sub create { |
| 22 |
my ($self) = @_; |
| 23 |
$schema->resultset('Branchrelation')->create({%{$self}}); |
| 24 |
} |
| 25 |
|
| 26 |
sub read { |
| 27 |
my ($self, $branchrelation) = @_; |
| 28 |
return $schema->resultset('Branchrelation')->search($branchrelation); |
| 29 |
} |
| 30 |
|
| 31 |
sub update { |
| 32 |
my ($self, $branchrelation) = @_; |
| 33 |
return $schema->resultset('Branchrelation')->search({branchcode => $branchrelation->{branchcode}})->update($branchrelation); |
| 34 |
} |
| 35 |
|
| 36 |
sub delete { |
| 37 |
my ($self,$branchrelation) = @_; |
| 38 |
$schema->resultset('Branchrelation')->search($branchrelation)->delete; |
| 39 |
} |
| 40 |
|