Line 0
Link Here
|
|
|
1 |
package Koha::DB::Branch; |
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 |
my $schema = Koha::Schema->connect( |
11 |
'dbi:mysql:dbname='.C4::Context->config("database"), |
12 |
C4::Context->config("user"), |
13 |
C4::Context->config("pass"), |
14 |
{ AutoCommit => 1 }, |
15 |
); |
16 |
|
17 |
sub create { |
18 |
my ($self, $branch) = @_; |
19 |
$schema->resultset('Branch')->create($branch); |
20 |
} |
21 |
|
22 |
sub read { |
23 |
my ($self, $branch) = @_; |
24 |
return $schema->resultset('Branch')->search($branch); |
25 |
} |
26 |
|
27 |
sub update { |
28 |
my ($self, $branch) = @_; |
29 |
return $schema->resultset('Branch')->search({branchcode => $branch->{branchcode}})->update($branch); |
30 |
} |
31 |
|
32 |
sub delete { |
33 |
my ($self,$branch) = @_; |
34 |
$schema->resultset('Branch')->search($branch)->delete; |
35 |
} |
36 |
|