4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
package Ox::WebMail::Consts;
use vars '$VERSION';
$VERSION = '0.01';
use constant {
DATABASE_SOURCE => "dbi:SQLite2:dbname=../db.sqlite2",
DATABASE_USERNAME => "",
DATABASE_PASSWORD => "",
DATABASE_PREFIX => "OxWebMail_",
};
1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
package Ox::WebMail::DBI;
use vars '$VERSION';
$VERSION = '0.01';
use Ox::WebMail::Consts ();
use base 'Class::DBI';
->set_db(
'Main',
Ox::WebMail::Consts::DATABASE_SOURCE,
Ox::WebMail::Consts::DATABASE_USERNAME,
Ox::WebMail::Consts::DATABASE_PASSWORD,
);
1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
package Ox::WebMail::User;
use vars '$VERSION';
$VERSION = '0.01';
use Ox::WebMail::Consts ();
use base 'Ox::WebMail::DBI';
->table(Ox::WebMail::Consts::DATABASE_PREFIX.'user');
sub new {
my ($parent, %args) = @_;
my $class = ref($parent) || $parent;
my $self = bless {}, $class;
return $self;
}
sub add {
my ($self, %data) = @_;
return $self->create(\%data);
}
1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
use strict;
use warnings;
BEGIN {
use FindBin;
use lib (
"$FindBin::Bin",
"$FindBin::Bin/../Lib",
"$FindBin::Bin/../Packages"
);
$ENV{TMPDIR} = $ENV{TEMP} || "";
};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer =:-)
use Ox::WebMail::User;
my $userdb = new Ox::WebMail::User;
my $id = $userdb->add(
username => 'esskar',
password => 'uhu'
);
print "$id\n";
1
2
3
4
5
6
7
8
9
BEGIN {
use FindBin;
use lib (
"$FindBin::Bin",
"$FindBin::Bin/../Lib",
"$FindBin::Bin/../Packages"
);
$ENV{TMPDIR} = $ENV{TEMP} || "";
};
4 Einträge, 1 Seite |