packaging one directory
|
1 |
package DBIx::Custom::SQLite; |
2 | ||
3 |
use strict; |
|
update document
|
4 |
use warnings; |
rename DBIx::Custom::SQLite ...
|
5 | |
update document
|
6 |
use base 'DBIx::Custom'; |
7 | ||
packaging one directory
|
8 |
use Carp 'croak'; |
9 | ||
update document
|
10 |
__PACKAGE__->attr('database'); |
11 | ||
packaging one directory
|
12 |
sub connect { |
update document
|
13 |
my $proto = shift; |
14 |
|
|
15 |
# Create |
|
16 |
my $self = ref $proto ? $proto : $proto->new(@_); |
|
packaging one directory
|
17 |
|
rename DBIx::Custom::SQLite ...
|
18 |
# Create data source |
packaging one directory
|
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
|
38 |
sub last_insert_rowid { shift->dbh->func('last_insert_rowid') } |
packaging one directory
|
39 | |
removed register_format()
|
40 |
1; |
41 | ||
packaging one directory
|
42 |
=head1 NAME |
43 | ||
update document
|
44 |
DBIx::Custom::SQLite - a SQLite implementation of DBIx::Custom |
packaging one directory
|
45 | |
rename DBIx::Custom::SQLite ...
|
46 |
=head1 SYNOPSYS |
packaging one directory
|
47 | |
48 |
use DBIx::Custom::SQLite; |
|
49 |
|
|
update document
|
50 |
# Connect |
51 |
my $dbi = DBIx::Custom::SQLite->connect(user => 'taro', |
|
52 |
password => 'kl&@K', |
|
53 |
database => 'your_database'); |
|
packaging one directory
|
54 |
|
version 0.0901
|
55 |
# Connect memory database |
update document
|
56 |
my $dbi = DBIx::Custom::SQLite->connect_memory; |
57 |
|
|
58 |
# Last insert row ID |
|
59 |
my $id = $dbi->last_insert_rowid; |
|
packaging one directory
|
60 |
|
update document
|
61 |
=head1 ATTRIBUTES |
62 | ||
63 |
This class is L<DBIx::Custom> subclass. |
|
64 |
You can use all attributes of L<DBIx::Custom>. |
|
65 | ||
66 |
=head2 database |
|
67 | ||
68 |
Database name |
|
69 | ||
70 |
$dbi = $dbi->database('your_database'); |
|
71 |
$database = $dbi->database; |
|
packaging one directory
|
72 | |
rename DBIx::Custom::SQLite ...
|
73 |
=head1 METHODS |
packaging one directory
|
74 | |
update document
|
75 |
This class is L<DBIx::Custom> subclass. |
76 |
You can use all methods of L<DBIx::Custom>. |
|
packaging one directory
|
77 | |
update document
|
78 |
=head2 connect - overridden |
packaging one directory
|
79 | |
update document
|
80 |
Connect to database. |
packaging one directory
|
81 | |
82 |
$dbi->connect; |
|
83 | ||
version 0.0901
|
84 |
If you set database, host, or port, data source is automatically created. |
packaging one directory
|
85 | |
86 |
=head2 connect_memory |
|
87 | ||
update document
|
88 |
Connect memory database. |
update document
|
89 | |
90 |
$dbi->connect_memory; |
|
packaging one directory
|
91 | |
rename DBIx::Custom::SQLite ...
|
92 |
=head2 last_insert_rowid |
add Oracle, DB2, Pg,
|
93 | |
update document
|
94 |
Last insert row ID. |
update document
|
95 | |
rename DBIx::Custom::SQLite ...
|
96 |
$last_insert_rowid = $dbi->last_insert_rowid; |
update document
|
97 |
|
update document
|
98 |
This is equal to SQLite last_insert_rowid() function. |
add Oracle, DB2, Pg,
|
99 | |
rename DBIx::Custom::SQLite ...
|
100 |
=cut |