line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jifty::DBI::Handle::mysql; |
2
|
1
|
|
|
1
|
|
1238
|
use Jifty::DBI::Handle; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
@ISA = qw(Jifty::DBI::Handle); |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use vars qw($VERSION @ISA $DBIHandle $DEBUG); |
6
|
|
|
|
|
|
|
use strict; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Jifty::DBI::Handle::mysql - A mysql specific Handle object |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module provides a subclass of L<Jifty::DBI::Handle> that |
18
|
|
|
|
|
|
|
compensates for some of the idiosyncrasies of MySQL. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 insert |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Takes a table name as the first argument and assumes that the rest of |
27
|
|
|
|
|
|
|
the arguments are an array of key-value pairs to be inserted. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
If the insert succeeds, returns the id of the insert, otherwise, |
30
|
|
|
|
|
|
|
returns a L<Class::ReturnValue> object with the error reported. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub insert { |
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $sth = $self->SUPER::insert(@_); |
38
|
|
|
|
|
|
|
if ( !$sth ) { |
39
|
|
|
|
|
|
|
return ($sth); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->{'id'} = $self->dbh->{'mysql_insertid'}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Yay. we get to work around mysql_insertid being null some of the time :/ |
45
|
|
|
|
|
|
|
unless ( $self->{'id'} ) { |
46
|
|
|
|
|
|
|
$self->{'id'} = $self->fetch_result('SELECT LAST_INSERT_ID()'); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
warn "$self no row id returned on row creation" unless ( $self->{'id'} ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return ( $self->{'id'} ); #Add Succeded. return the id |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 database_version |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the mysql version, trimming off any -foo identifier |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub database_version { |
60
|
|
|
|
|
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
my $v = $self->SUPER::database_version(); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$v =~ s/\-.*$//; |
64
|
|
|
|
|
|
|
return ($v); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 case_sensitive |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns undef, since mysql's searches are not case sensitive by default |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub case_sensitive { |
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
return (undef); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Jesse Vincent, jesse@fsck.com |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::mysql> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|