Newer Older
100 lines | 1.949kb
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 {
27
    my $self = shift;
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

            
update document
yuki-kimoto authored on 2010-05-27
44
DBIx::Custom::SQLite - a SQLite implementation of DBIx::Custom
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
    
update document
yuki-kimoto authored on 2010-05-27
50
    # Connect
51
    my $dbi = DBIx::Custom::SQLite->connect(user      => 'taro', 
52
                                            password => 'kl&@K',
53
                                            database  => 'your_database');
packaging one directory
yuki-kimoto authored on 2009-11-16
54
    
version 0.0901
yuki-kimoto authored on 2009-12-17
55
    # Connect memory database
update document
yuki-kimoto authored on 2010-05-27
56
    my $dbi = DBIx::Custom::SQLite->connect_memory;
57
    
58
    # Last insert row ID
59
    my $id = $dbi->last_insert_rowid;
packaging one directory
yuki-kimoto authored on 2009-11-16
60
    
update document
yuki-kimoto authored on 2010-05-27
61
=head1 ATTRIBUTES
62

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

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

            
68
Database name
69

            
70
    $dbi      = $dbi->database('your_database');
71
    $database = $dbi->database;
packaging one directory
yuki-kimoto authored on 2009-11-16
72

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

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

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
78
=head2 C<connect (overridden)>
packaging one directory
yuki-kimoto authored on 2009-11-16
79

            
update document
yuki-kimoto authored on 2010-05-27
80
Connect to database.
packaging one directory
yuki-kimoto authored on 2009-11-16
81

            
82
    $dbi->connect;
83

            
version 0.0901
yuki-kimoto authored on 2009-12-17
84
If you set database, host, or port, data source is automatically created.
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 2010-05-27
88
Connect memory database.
update document
yuki-kimoto authored on 2009-11-19
89

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

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
92
=head2 C<last_insert_rowid>
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
93

            
update document
yuki-kimoto authored on 2010-05-27
94
Last insert row ID.
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;
update document
yuki-kimoto authored on 2009-11-19
97
    
update document
yuki-kimoto authored on 2010-05-27
98
This is equal to SQLite last_insert_rowid() function.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
99

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