|
Lines 27-32
use C4::Debug;
Link Here
|
| 27 |
require Exporter; |
27 |
require Exporter; |
| 28 |
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
28 |
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
| 29 |
|
29 |
|
|
|
30 |
eval { |
| 31 |
my $servers = C4::Context->config('memcached_servers'); |
| 32 |
if ($servers) { |
| 33 |
require Memoize::Memcached; |
| 34 |
import Memoize::Memcached qw(memoize_memcached); |
| 35 |
|
| 36 |
my $memcached = { |
| 37 |
servers => [$servers], |
| 38 |
key_prefix => C4::Context->config('memcached_namespace') || 'koha', |
| 39 |
}; |
| 40 |
|
| 41 |
memoize_memcached( '_get_columns', memcached => $memcached, expire_time => 600000 ); #cache for 10 minutes |
| 42 |
memoize_memcached( 'GetPrimaryKeys', memcached => $memcached, expire_time => 600000 ); #cache for 10 minutes |
| 43 |
} |
| 44 |
}; |
| 45 |
|
| 30 |
BEGIN { |
46 |
BEGIN { |
| 31 |
# set the version for version checking |
47 |
# set the version for version checking |
| 32 |
$VERSION = 0.5; |
48 |
$VERSION = 0.5; |
|
Lines 43-48
BEGIN {
Link Here
|
| 43 |
); |
59 |
); |
| 44 |
} |
60 |
} |
| 45 |
|
61 |
|
|
|
62 |
my $tablename; |
| 63 |
my $hashref; |
| 64 |
|
| 46 |
=head1 NAME |
65 |
=head1 NAME |
| 47 |
|
66 |
|
| 48 |
C4::SQLHelper - Perl Module containing convenience functions for SQL Handling |
67 |
C4::SQLHelper - Perl Module containing convenience functions for SQL Handling |
|
Lines 247-262
With
Link Here
|
| 247 |
=cut |
266 |
=cut |
| 248 |
|
267 |
|
| 249 |
sub _get_columns($) { |
268 |
sub _get_columns($) { |
| 250 |
my ($tablename)=@_; |
269 |
my ($tablename) = @_; |
| 251 |
my $dbh=C4::Context->dbh; |
270 |
unless ( exists( $hashref->{$tablename} ) ) { |
| 252 |
my $sth=$dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename }); |
271 |
my $dbh = C4::Context->dbh; |
| 253 |
$sth->execute; |
272 |
my $sth = $dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename }); |
| 254 |
my $columns= $sth->fetchall_hashref(qw(Field)); |
273 |
$sth->execute; |
|
|
274 |
my $columns = $sth->fetchall_hashref(qw(Field)); |
| 275 |
$hashref->{$tablename} = $columns; |
| 276 |
} |
| 277 |
return $hashref->{$tablename}; |
| 255 |
} |
278 |
} |
| 256 |
|
279 |
|
| 257 |
=head2 _filter_columns |
280 |
=head2 _filter_columns |
| 258 |
|
281 |
|
| 259 |
_filter_columns($tablename,$research, $filtercolumns) |
282 |
=over 4 |
|
|
283 |
|
| 284 |
_filter_columns($tablename,$research, $filtercolumns) |
| 285 |
|
| 286 |
=back |
| 260 |
|
287 |
|
| 261 |
Given |
288 |
Given |
| 262 |
- a tablename |
289 |
- a tablename |
| 263 |
- |
|
|