line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Class::DBI::Lite::SQLite; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
2504
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings 'all'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
6
|
2
|
|
|
2
|
|
12
|
use base 'Class::DBI::Lite'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
577
|
|
7
|
2
|
|
|
2
|
|
13
|
use Carp 'confess'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
466
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#============================================================================== |
11
|
|
|
|
|
|
|
sub set_up_table |
12
|
|
|
|
|
|
|
{ |
13
|
6
|
|
|
6
|
0
|
14975
|
my $s = shift; |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
|
|
42
|
$s->_init_meta; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Get our columns: |
18
|
6
|
|
|
|
|
5
|
my $table = shift; |
19
|
6
|
|
|
|
|
30
|
$s->_meta->{table} = $table; |
20
|
6
|
|
|
|
|
32
|
my $sth = $s->db_Main->prepare(<<""); |
21
|
|
|
|
|
|
|
PRAGMA table_info( '$table' ) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Simple discovery of fields and PK: |
24
|
6
|
|
|
|
|
21705
|
$sth->execute( ); |
25
|
6
|
|
|
|
|
648
|
my @cols = ( ); |
26
|
6
|
|
|
|
|
5
|
my $PK; |
27
|
6
|
|
|
|
|
80
|
while( my $rec = $sth->fetchrow_hashref ) |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
# Is this the primary column?: |
30
|
|
|
|
|
|
|
$PK = $rec->{name} |
31
|
22
|
100
|
|
|
|
249
|
if $rec->{pk}; |
32
|
22
|
|
|
|
|
187
|
push @cols, $rec->{name}; |
33
|
|
|
|
|
|
|
}# end while() |
34
|
6
|
|
|
|
|
58
|
$sth->finish(); |
35
|
|
|
|
|
|
|
|
36
|
6
|
50
|
|
|
|
17
|
confess "Table $table doesn't exist or has no columns" |
37
|
|
|
|
|
|
|
unless @cols; |
38
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
53
|
$s->columns( Primary => $PK ); |
40
|
6
|
|
|
|
|
16
|
$s->columns( Essential => @cols ); |
41
|
6
|
|
|
|
|
16
|
$s->columns( All => @cols ); |
42
|
6
|
|
|
|
|
88
|
1; |
43
|
|
|
|
|
|
|
}# end set_up_table() |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#============================================================================== |
47
|
|
|
|
|
|
|
sub get_last_insert_id |
48
|
|
|
|
|
|
|
{ |
49
|
125
|
|
|
125
|
0
|
475
|
$_[0]->db_Main->func('last_insert_rowid'); |
50
|
|
|
|
|
|
|
}# end get_last_insert_id() |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1;# return true: |
53
|
|
|
|
|
|
|
|