Newer Older
101 lines | 2.kb
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

            
packaging one directory
yuki-kimoto authored on 2009-11-16
8
use Carp 'croak';
9

            
update document
yuki-kimoto authored on 2010-05-27
10
__PACKAGE__->attr('database');
11

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

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

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

            
removed register_format()
yuki-kimoto authored on 2010-05-26
40
1;
41

            
packaging one directory
yuki-kimoto authored on 2009-11-16
42
=head1 NAME
43

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

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

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

            
61
This class is L<DBIx::Custom> subclass.
62
You can use all attributes of L<DBIx::Custom>.
63

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

            
cleanup
yuki-kimoto authored on 2010-08-03
66
    my $database = $dbi->database;
67
    $dbi         = $dbi->database('your_database');
packaging one directory
yuki-kimoto authored on 2009-11-16
68

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
69
Database name.
70
This is used for connect().
71

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

            
update document
yuki-kimoto authored on 2010-05-27
74
This class is L<DBIx::Custom> subclass.
75
You can use all methods of L<DBIx::Custom>.
packaging one directory
yuki-kimoto authored on 2009-11-16
76

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
77
=head2 C<connect (overridden)>
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
78
    
79
    $dbi = DBIx::Custom::SQLite->connect(
80
        data_source  => "dbi:SQLite:dbname=your_db"
81
    );
82
    
83
    $dbi = DBIx::Custom::SQLite->connect(database  => 'your_db');
packaging one directory
yuki-kimoto authored on 2009-11-16
84

            
update document
yuki-kimoto authored on 2010-05-27
85
Connect to database.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
86
You can also specify database name, instead of data source.
packaging one directory
yuki-kimoto authored on 2009-11-16
87

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

            
update document
yuki-kimoto authored on 2009-11-19
90
    $dbi->connect_memory;
packaging one directory
yuki-kimoto authored on 2009-11-16
91

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
92
Connect to memory database.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
93

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

            
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
96
    $last_insert_rowid = $dbi->last_insert_rowid;
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
97

            
98
Get last insert row id.
update document
yuki-kimoto authored on 2010-05-27
99
This is equal to SQLite last_insert_rowid() function.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
100

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