line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Generic; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use Rose::DB; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
378
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Object methods |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub build_dsn |
14
|
|
|
|
|
|
|
{ |
15
|
2
|
|
|
2
|
0
|
16
|
my($self_or_class, %args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
6
|
my %info; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
33
|
|
|
20
|
$info{'dbname'} = $args{'db'} || $args{'database'}; |
20
|
2
|
|
|
|
|
7
|
$info{'host'} = $args{'host'}; |
21
|
2
|
|
|
|
|
6
|
$info{'port'} = $args{'port'}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return |
24
|
|
|
|
|
|
|
"dbi:$args{'dbi_driver'}:" . |
25
|
2
|
|
|
|
|
11
|
join(';', map { "$_=$info{$_}" } grep { defined $info{$_} } |
|
4
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
16
|
|
26
|
|
|
|
|
|
|
qw(dbname host port)); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
0
|
0
|
|
sub last_insertid_from_sth { } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Rose::DB::Generic - Generic driver class for Rose::DB. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use Rose::DB; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Rose::DB->register_db( |
44
|
|
|
|
|
|
|
dsn => 'dbi:SomeDB:...', # unknown driver |
45
|
|
|
|
|
|
|
username => 'devuser', |
46
|
|
|
|
|
|
|
password => 'mysecret', |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Rose::DB->default_domain('development'); |
50
|
|
|
|
|
|
|
Rose::DB->default_type('main'); |
51
|
|
|
|
|
|
|
... |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$db = Rose::DB->new; # $db is really a Rose::DB::Generic object |
54
|
|
|
|
|
|
|
... |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is the subclass that L<Rose::DB> blesses an object into (by default) when the L<driver|Rose::DB::Registry::Entry/driver> specified in the registry entry is has no class name registered in the L<driver class map|Rose::DB/driver_class>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
To maximize the chance that this class will work with an unsupported database, do the following. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * Use a L<driver|Rose::DB::Registry::Entry/driver> name that exactly matches the L<DBI> "DBD::..." driver name. Even though L<Rose::DB> L<driver|Rose::DB::Registry::Entry/driver>s are case-insensitive, using the exact spelling and letter case will allow this generic L<Rose::DB> driver to connect successfully. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * Specify the DSN explicitly rather than providing the pieces separately (host, database, port, etc.) and then relying upon this class to assemble them into L<DBI> DSN. This class will assemble a DSN, but it may not be in the format that an unsupported driver expects. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This class inherits from L<Rose::DB>. See the L<Rose::DB> documentation for information on the inherited methods. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 LICENSE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
79
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
80
|
|
|
|
|
|
|
as Perl itself. |