/[Semantic-Engine]/EPrints/EPrints.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /EPrints/EPrints.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Fri Jun 29 09:21:11 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 1042 byte(s)
basic tests and move DBI to EPrints where it belongs
1 # Dobrica Pavlinusic, <dpavlin@rot13.org> 06/28/07 23:28:21 CEST
2
3 package EPrints;
4
5 use Exporter 'import';
6 @EXPORT_OK = qw(_x);
7
8 use Encode qw/from_to decode_utf8 decode/;
9 use Data::Dump qw/dump/;
10 use DBI;
11
12 use strict;
13 use warnings;
14
15 my $debug = 0;
16
17 my $connect = "DBI:mysql:dbname=eprints";
18
19 my $dbh = DBI->connect($connect,"dpavlin","") || die $DBI::errstr;
20
21 sub dbh {
22 my $self = shift;
23 return $dbh;
24 }
25
26 my $id;
27
28 sub id {
29 my $self = shift;
30 if ( defined( $_[0] ) ) {
31 $id = $_[0];
32 warn "# id = $id\n" if $debug;
33 }
34 return $id;
35 }
36
37 sub lookup {
38 my $self = shift;
39 my $field = shift;
40
41 my $sql = qq{
42 SELECT $field
43 FROM archive_$field
44 WHERE eprintid = $id
45 };
46 warn "# sql: $sql\n" if $debug;
47 my @results = map { _x( $_->{$field} ) } @{ $dbh->selectall_arrayref($sql, { Slice => {} }) };
48
49 warn "# loookup( $field, $id ) = ", dump( @results ),$/ if $debug;
50 return join(" ", @results);
51 }
52
53 sub _x {
54 my $v = join(" ", @_);
55 decode_utf8( $v );
56 from_to( $v, 'utf-8', 'iso-8859-2' );
57 warn "_x($v)\n" if $debug;
58 return "$v ";
59 }
60
61 1;

  ViewVC Help
Powered by ViewVC 1.1.26