packaging one directory
|
1 |
package DBIx::Custom::SQLite; |
2 | ||
3 |
use strict; |
|
update document
|
4 |
use warnings; |
rename DBIx::Custom::SQLite ...
|
5 | |
6 |
use base 'DBIx::Custom::Basic'; |
|
packaging one directory
|
7 |
use Carp 'croak'; |
8 | ||
9 |
sub connect { |
|
10 |
my $self = shift; |
|
11 |
|
|
rename DBIx::Custom::SQLite ...
|
12 |
# Create data source |
packaging one directory
|
13 |
if (!$self->data_source && (my $database = $self->database)) { |
14 |
$self->data_source("dbi:SQLite:dbname=$database"); |
|
15 |
} |
|
16 |
|
|
17 |
return $self->SUPER::connect; |
|
18 |
} |
|
19 | ||
20 |
sub connect_memory { |
|
21 |
my $self = shift; |
|
22 |
|
|
23 |
# Data source for memory database |
|
24 |
$self->data_source('dbi:SQLite:dbname=:memory:'); |
|
25 |
|
|
26 |
# Already connected |
|
27 |
croak("Already connected") if $self->connected; |
|
28 |
|
|
29 |
# Connect |
|
30 |
$self->connect; |
|
31 |
|
|
32 |
return $self; |
|
33 |
} |
|
34 | ||
35 |
sub reconnect_memory { |
|
36 |
my $self = shift; |
|
37 | ||
38 |
# Data source for memory database |
|
39 |
$self->data_source('dbi:SQLite:dbname=:memory:'); |
|
40 |
|
|
41 |
# Reconnect |
|
42 |
$self->reconnect; |
|
43 |
|
|
44 |
return $self; |
|
45 |
} |
|
46 | ||
rename DBIx::Custom::SQLite ...
|
47 |
sub last_insert_rowid { |
add Oracle, DB2, Pg,
|
48 |
my $self = shift; |
49 |
|
|
rename DBIx::Custom::SQLite ...
|
50 |
# Not connected |
add Oracle, DB2, Pg,
|
51 |
croak "Not yet connected" unless $self->connected; |
52 |
|
|
rename DBIx::Custom::SQLite ...
|
53 |
# Get last insert row id |
54 |
my $last_insert_rowid = $self->dbh->func('last_insert_rowid'); |
|
add Oracle, DB2, Pg,
|
55 |
|
rename DBIx::Custom::SQLite ...
|
56 |
return $last_insert_rowid; |
add Oracle, DB2, Pg,
|
57 |
} |
packaging one directory
|
58 | |
removed register_format()
|
59 |
1; |
60 | ||
packaging one directory
|
61 |
=head1 NAME |
62 | ||
63 |
DBIx::Custom::SQLite - DBIx::Custom SQLite implementation |
|
64 | ||
rename DBIx::Custom::SQLite ...
|
65 |
=head1 SYNOPSYS |
packaging one directory
|
66 | |
67 |
use DBIx::Custom::SQLite; |
|
68 |
|
|
69 |
# New |
|
rename DBIx::Custom::SQLite ...
|
70 |
my $dbi = DBIx::Custom::SQLite->new(user => 'taro', $password => 'kl&@K', |
update document
|
71 |
database => 'sample'); |
packaging one directory
|
72 |
|
version 0.0901
|
73 |
# Connect memory database |
74 |
my $dbi->connect_memory; |
|
packaging one directory
|
75 |
|
76 | ||
rename DBIx::Custom::SQLite ...
|
77 |
=head1 METHODS |
packaging one directory
|
78 | |
rename DBIx::Custom::SQLite ...
|
79 |
This class is L<DBIx::Custom::Basic> subclass. |
80 |
You can use all methods of L<DBIx::Custom::Basic> |
|
packaging one directory
|
81 | |
82 |
=head2 connect |
|
83 | ||
update document
|
84 |
Connect to database |
packaging one directory
|
85 | |
86 |
$dbi->connect; |
|
87 | ||
version 0.0901
|
88 |
If you set database, host, or port, data source is automatically created. |
packaging one directory
|
89 | |
90 |
=head2 connect_memory |
|
91 | ||
update document
|
92 |
Connect memory database |
93 | ||
94 |
$dbi->connect_memory; |
|
packaging one directory
|
95 | |
96 |
=head2 reconnect_memory |
|
97 | ||
update document
|
98 |
Reconnect to memory databsse |
99 | ||
version 0.0901
|
100 |
$dbi->reconnect_memory; |
packaging one directory
|
101 | |
rename DBIx::Custom::SQLite ...
|
102 |
=head2 last_insert_rowid |
add Oracle, DB2, Pg,
|
103 | |
update document
|
104 |
Get last insert id |
105 | ||
rename DBIx::Custom::SQLite ...
|
106 |
$last_insert_rowid = $dbi->last_insert_rowid; |
update document
|
107 |
|
rename DBIx::Custom::SQLite ...
|
108 |
The folloing is last_insert_rowid sample. |
version 0.0901
|
109 | |
update document
|
110 |
$dbi->insert('books', {title => 'Perl', author => 'taro'}); |
rename DBIx::Custom::SQLite ...
|
111 |
$last_insert_rowid = $dbi->last_insert_rowid; |
add Oracle, DB2, Pg,
|
112 | |
113 |
This is equal to SQLite function |
|
114 | ||
115 |
last_insert_rowid() |
|
116 | ||
rename DBIx::Custom::SQLite ...
|
117 |
=cut |