Newer Older
99 lines | 1.981kb
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
    
13
    # Create
14
    my $self = ref $proto ? $proto : $proto->new(@_);
packaging one directory
yuki-kimoto authored on 2009-11-16
15
    
rename DBIx::Custom::SQLite ...
yuki-kimoto authored on 2010-01-30
16
    # Create 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
    
27
    # Data source for memory database
28
    $self->data_source('dbi:SQLite:dbname=:memory:');
29
    
30
    # Connect
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
    
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
48
    # Connect to database
49
    my $dbi = DBIx::Custom::SQLite->connect(database  => 'dbname');
packaging one directory
yuki-kimoto authored on 2009-11-16
50
    
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
51
    # Connect to 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

            
59
This class is L<DBIx::Custom> subclass.
60
You can use all attributes of L<DBIx::Custom>.
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;
65
    $dbi         = $dbi->database('your_database');
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.
68
This is used for connect().
69

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

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

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

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

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

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

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

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

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

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

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