Newer Older
98 lines | 2.207kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::SQLite;
2

            
3
use strict;
update document
yuki-kimoto authored on 2009-11-17
4
use warnings;
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
5

            
update document
yuki-kimoto authored on 2010-05-27
6
use base 'DBIx::Custom';
7

            
8
__PACKAGE__->attr('database');
9

            
packaging one directory
yuki-kimoto authored on 2009-11-16
10
sub connect {
update document
yuki-kimoto authored on 2010-05-27
11
    my $proto = shift;
12
    
cleanup
yuki-kimoto authored on 2010-08-05
13
    # Create a new object
update document
yuki-kimoto authored on 2010-05-27
14
    my $self = ref $proto ? $proto : $proto->new(@_);
packaging one directory
yuki-kimoto authored on 2009-11-16
15
    
cleanup
yuki-kimoto authored on 2010-08-05
16
    # Data source
packaging one directory
yuki-kimoto authored on 2009-11-16
17
    if (!$self->data_source && (my $database = $self->database)) {
18
        $self->data_source("dbi:SQLite:dbname=$database");
19
    }
20
    
21
    return $self->SUPER::connect;
22
}
23

            
24
sub connect_memory {
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
25
    my $self = shift->new(@_);
packaging one directory
yuki-kimoto authored on 2009-11-16
26
    
cleanup
yuki-kimoto authored on 2010-08-05
27
    # Data source
packaging one directory
yuki-kimoto authored on 2009-11-16
28
    $self->data_source('dbi:SQLite:dbname=:memory:');
29
    
cleanup
yuki-kimoto authored on 2010-08-05
30
    # Connect to database
packaging one directory
yuki-kimoto authored on 2009-11-16
31
    $self->connect;
32
    
33
    return $self;
34
}
35

            
removed reconnect method
yuki-kimoto authored on 2010-05-28
36
sub last_insert_rowid { shift->dbh->func('last_insert_rowid') }
packaging one directory
yuki-kimoto authored on 2009-11-16
37

            
removed register_format()
yuki-kimoto authored on 2010-05-26
38
1;
39

            
packaging one directory
yuki-kimoto authored on 2009-11-16
40
=head1 NAME
41

            
cleanup
yuki-kimoto authored on 2010-08-03
42
DBIx::Custom::SQLite - SQLite implementation
packaging one directory
yuki-kimoto authored on 2009-11-16
43

            
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
44
=head1 SYNOPSYS
packaging one directory
yuki-kimoto authored on 2009-11-16
45

            
46
    use DBIx::Custom::SQLite;
47
    
cleanup
yuki-kimoto authored on 2010-08-05
48
    # Connect to the database
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
49
    my $dbi = DBIx::Custom::SQLite->connect(database  => 'dbname');
packaging one directory
yuki-kimoto authored on 2009-11-16
50
    
cleanup
yuki-kimoto authored on 2010-08-05
51
    # Connect to the memory database
update document
yuki-kimoto authored on 2010-05-27
52
    my $dbi = DBIx::Custom::SQLite->connect_memory;
53
    
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
54
    # Get last insert row id
update document
yuki-kimoto authored on 2010-05-27
55
    my $id = $dbi->last_insert_rowid;
packaging one directory
yuki-kimoto authored on 2009-11-16
56
    
update document
yuki-kimoto authored on 2010-05-27
57
=head1 ATTRIBUTES
58

            
cleanup
yuki-kimoto authored on 2010-08-05
59
L<DBIx::Custom::SQLite> inherits all attributes from L<DBIx::Custom>
60
and implements the following new ones.
update document
yuki-kimoto authored on 2010-05-27
61

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
62
=head2 C<database>
update document
yuki-kimoto authored on 2010-05-27
63

            
cleanup
yuki-kimoto authored on 2010-08-03
64
    my $database = $dbi->database;
cleanup
yuki-kimoto authored on 2010-08-05
65
    $dbi         = $dbi->database('dbname');
packaging one directory
yuki-kimoto authored on 2009-11-16
66

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
67
Database name.
cleanup
yuki-kimoto authored on 2010-08-05
68
C<connect()> method use this value to connect the database
69
if C<data_source> is not specified.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
70

            
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
71
=head1 METHODS
packaging one directory
yuki-kimoto authored on 2009-11-16
72

            
cleanup
yuki-kimoto authored on 2010-08-05
73
L<DBIx::Custom::SQLite> inherits all methods from L<DBIx::Custom>
74
and implements the following new ones.
packaging one directory
yuki-kimoto authored on 2009-11-16
75

            
cleanup
yuki-kimoto authored on 2010-08-05
76
=head2 C<connect>
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
77
    
cleanup
yuki-kimoto authored on 2010-08-05
78
    my $dbi = DBIx::Custom::SQLite->connect(database  => 'dbname');
packaging one directory
yuki-kimoto authored on 2009-11-16
79

            
cleanup
yuki-kimoto authored on 2010-08-05
80
Create a new L<DBIx::Custom::SQLite> object and connect to the database.
cleanup
yuki-kimoto authored on 2010-08-05
81
This method overrides C<DBIx::Custom::connect()> method.
cleanup
yuki-kimoto authored on 2010-08-05
82
You can specify all attributes of L<DBIx::Custom>
83
and L<DBIx::Custom::SQLite>, such as C<database>.
packaging one directory
yuki-kimoto authored on 2009-11-16
84

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
85
=head2 C<connect_memory>
packaging one directory
yuki-kimoto authored on 2009-11-16
86

            
cleanup
yuki-kimoto authored on 2010-08-05
87
    my $dbi = DBIx::Custom::SQLite->connect_memory;
packaging one directory
yuki-kimoto authored on 2009-11-16
88

            
cleanup
yuki-kimoto authored on 2010-08-05
89
Create a new L<DBIx::Custom::SQLite> object and connect to the memory database.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
90

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
91
=head2 C<last_insert_rowid>
update document
yuki-kimoto authored on 2009-11-19
92

            
cleanup
yuki-kimoto authored on 2010-08-05
93
    my $last_insert_rowid = $dbi->last_insert_rowid;
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
94

            
95
Get last insert row id.
cleanup
yuki-kimoto authored on 2010-08-05
96
This is same as C<last_insert_rowid()> function in SQLite.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
97

            
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
98
=cut