blib/lib/DBIx/Raw.pm

filter: Statementstmt 88.5% 310 / 350 Branchbran 77.2% 122 / 158 Conditioncond 45.8% 33 / 72 MC/DCmcdc 7.6% 3 / 39 Subroutinesub 85.7% 36 / 42 Podpod 92.3% 12 / 13 totaltotal 76.5% 516 / 674 SCAR 53.3
CC
111
Cov
80%
insert
90.0
raw
21.3
update
20.7
CRAP 207.0
↑ Summary blib/lib/DBIx/Raw/Crypt.pm »
1 package DBIx::Raw;
2  
3 71 ▶use 5.008_005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 71 our $VERSION = '0.21';
5  
6 71 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 71 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 71 ▶use Types::Standard qw/Bool HashRef InstanceOf Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 71 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 71 ▶use Config::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 71 ▶use DBIx::Raw::Crypt;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 71 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 71 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 71 ▶use Crypt::Mode::CBC::Easy;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #have an errors file to write to
17 71 has 'dsn' => is => 'rw';
18 71 has 'user' => is => 'rw';
19 71 has 'password' => is => 'rw';
20 71 has 'conf' => is => 'rw';
21 71 has 'prev_conf' => (
22 is => 'rw',
23 isa => Str,
24 default => '',
25 );
26  
27 has 'crypt' => (
28 is => 'ro',
29 isa => InstanceOf['Crypt::Mode::CBC::Easy'],
30 lazy => 1,
31 builder => sub {
32 15 ▶ my ($self) = @_;
Subroutine _build_crypt: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
33 15 return Crypt::Mode::CBC::Easy->new(key => $self->crypt_key);
34 },
35 71 );
36  
37 has 'crypt_key' => (
38 is => 'rw',
39 isa => Str,
40 lazy => 1,
41 builder => sub {
42 16 ▶ my $crypt_key_hex = 'aea77496999d37bf47aedff9c0d44fdf2d2bbfa848ee6652abe9891b43e0f331';
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build_crypt_key: called CC=1 SCAR=0.0
43 16 return pack "H*", $crypt_key_hex;
44 },
45 71 );
46  
47 71 has use_old_crypt => (
48 is => 'rw',
49 isa => Bool,
50 default => undef,
51 );
52  
53 71 has 'old_crypt_key' => (
54 is => 'rw',
55 isa => Str,
56 lazy => 1,
57 default => '6883868834006296591264051568595813693328016796531185824375212916576042669669556288781800326542091901603033335703884439231366552922364658270813734165084102xfasdfa8823423sfasdfalkj!@#$$CCCFFF!09xxxxlai3847lol13234408!!@#$_+-083dxje380-=0'
58 );
59  
60 has 'old_crypt' => (
61 is => 'ro',
62 isa => InstanceOf['DBIx::Raw::Crypt'],
63 lazy => 1,
64 builder => sub {
65 0 ▶ my ($self) = @_;
Subroutine _build_old_crypt: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 return DBIx::Raw::Crypt->new( { secret => $self->old_crypt_key });
67 },
68 71 );
69  
70 # LAST STH USED
71 71 has 'sth' => is => 'rw';
72  
73 #find out what DBH is specifically
74 has 'dbh' => (
75 is => 'rw',
76 lazy => 1,
77 67 ▶ default => sub { shift->connect }
Subroutine __ANON__: called CC=1 SCAR=0.0
78 71 );
79  
80 has 'keys' => (
81 is => 'ro',
82 isa => HashRef[Str],
83 default => sub { {
84 70 ▶ query => 1,
Subroutine __ANON__: called CC=1 SCAR=0.0
85 vals => 1,
86 encrypt => 1,
87 decrypt => 1,
88 key => 1,
89 href => 1,
90 table => 1,
91 where => 1,
92 pk => 1,
93 rows => 1,
94 id => 1,
95 } },
96 71 );
97  
98 sub BUILD {
99 70 ▶ my ($self) = @_;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
100 70 $self->_parse_conf;
101 70 $self->_validate_connect_info;
102 }
103  
104 =head1 NAME
105  
106 DBIx::Raw - Maintain control of SQL queries while still having a layer of abstraction above DBI
107  
108 =head1 SYNOPSIS
109  
110 DBIx::Raw allows you to have complete control over your SQL, while still providing useful functionality so you don't have to deal directly with L<DBI>.
111  
112 use DBIx::Raw;
113 my $db = DBIx::Raw->new(dsn => $dsn, user => $user, password => $password);
114  
115 #alternatively, use a conf file
116 my $db = DBIx::Raw->new(conf => '/path/to/conf.pl');
117  
118 #get single values in scalar context
119 my $name = $db->raw("SELECT name FROM people WHERE id=1");
120  
121 #get multiple values in list context
122 my ($name, $age) = $db->raw("SELECT name, age FROM people WHERE id=1");
123
124 #or
125 my @person = $db->raw("SELECT name, age FROM people WHERE id=1");
126  
127 #get hash when using scalar context but requesting multiple values
128 my $person = $db->raw("SELECT name, age FROM people where id=1");
129 my $name = $person->{name};
130 my $age = $person->{age};
131  
132 #also get hash in scalar context when selecting multiple values using '*'
133 my $person = $db->raw("SELECT * FROM people where id=1");
134 my $name = $person->{name};
135 my $age = $person->{age};
136  
137 #insert a record
138 $db->raw("INSERT INTO people (name, age) VALUES ('Sally', 26)");
139  
140 #insert a record with bind values to help prevent SQL injection
141 $db->raw("INSERT INTO people (name, age) VALUES (?, ?)", 'Sally', 26);
142  
143 #update records
144 my $num_rows_updated = $db->raw("UPDATE people SET name='Joe',age=34 WHERE id=1");
145  
146 #use bind values to help prevent SQL injection
147 my $num_rows_updated = $db->raw("UPDATE people SET name=?,age=? WHERE id=?", 'Joe', 34, 1);
148  
149 #also use bind values when selecting
150 my $name = $db->raw("SELECT name FROM people WHERE id=?", 1);
151  
152 #get multiple records as an array of hashes
153 my $people = $db->aoh("SELECT name, age FROM people");
154
155 for my $person (@$people) {
156 print "$person->{name} is $person->{age} years old\n";
157 }
158  
159 #update a record easily with a hash
160 my %update = (
161 name => 'Joe',
162 age => 34,
163 );
164  
165 #record with id=1 now has name=Joe an age=34
166 $db->update(href=>\%update, table => 'people', id=>1);
167  
168 #use alternate syntax to encrypt and decrypt data
169 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=? WHERE id=1", vals => ['Joe'], encrypt => [0]);
170  
171 my $decrypted_name = $db->raw(query => "SELECT name FROM people WHERE id=1", decrypt => [0]);
172  
173 #when being returned a hash, use names of field for decryption
174 my $decrypted_person = $db->raw(query => "SELECT name, age FROM people WHERE id=1", decrypt => ['name']);
175 my $decrypted_name = $decrypted_person->{name};
176  
177  
178 =head1 INITIALIZATION
179  
180 There are three ways to intialize a L<DBIx::Raw> object:
181  
182 =head2 dsn, user, password
183  
184 You can initialize a L<DBIx::Raw> object by passing in the dsn, user, and password connection information.
185  
186 my $db = DBIx::Raw->new(dsn => 'dbi:mysql:test:localhost:3306', user => 'user', password => 'password');
187  
188 =head2 dbh
189  
190 You can also initialize a L<DBIx::Raw> object by passing in an existing database handle.
191  
192 my $db = DBIx::Raw->new(dbh => $dbh);
193  
194 =head2 conf
195  
196 If you're going to using the same connection information a lot, it's useful to store it in a configuration file and then
197 use that when creating a L<DBIx::Raw> object.
198  
199 my $db = DBIx::Raw->new(conf => '/path/to/conf.pl');
200  
201 See L<CONFIGURATION FILE|DBIx::Raw/"CONFIGURATION FILE"> for more information on how to set up a configuration file.
202  
203 =head1 CONFIGURATION FILE
204  
205 You can use a configuration file to store settings for L<DBIx::Raw> instead of passing them into new or setting them.
206 L<DBIx::Raw> uses L<Config::Any>, so you can use any configuration format that is acceptable for L<Config::Any>. Variables
207 that you might want to store in your configuration file are C<dsn>, C<user>, C<password>, and L</crypt_key>.
208  
209 Below is an example configuration file in perl format:
210  
211 =head2 conf.pl
212  
213 {
214 dsn => 'dbi:mysql:test:localhost:3306',
215 user => 'root',
216 password => 'password',
217 crypt_key => 'lxsafadsfadskl23239210453453802xxx02-487900-=+1!:)',
218 }
219  
220 =head2 conf.yaml
221  
222 ---
223 dsn: 'dbi:mysql:test:localhost:3306'
224 user: 'root'
225 password: 'password'
226 crypt_key: 'lxsafadsfadskl23239210453453802xxx02-487900-=+1!:)'
227  
228 Note that you do not need to include L</crypt_key> if you just if you just want to use the file for configuration settings.
229  
230 =head1 SYNTAXES
231  
232 DBIx::Raw provides two different possible syntaxes when making queries.
233  
234 =head2 SIMPLE SYNTAX
235  
236 Simple syntax is an easy way to write queries. It is always in the format:
237  
238 ("QUERY");
239  
240 or
241  
242 ("QUERY", "VAL1", "VAL2", ...);
243  
244 Below are some examples:
245  
246 my $num_rows_updated = $db->raw("UPDATE people SET name='Fred'");
247  
248 my $name = $db->raw("SELECT name FROM people WHERE id=1");
249
250 DBIx::Raw also supports L<DBI/"Placeholders and Bind Values"> for L<DBI>. These can be useful to help prevent SQL injection. Below are
251 some examples of how to use placeholders and bind values with L</"SIMPLE SYNTAX">.
252  
253 my $num_rows_updated = $db->raw("UPDATE people SET name=?", 'Fred');
254  
255 my $name = $db->raw("SELECT name FROM people WHERE id=?", 1);
256  
257 $db->raw("INSERT INTO people (name, age) VALUES (?, ?)", 'Frank', 44);
258
259 Note that L</"SIMPLE SYNTAX"> cannot be used for L</hoh>, L</hoaoh>, L</hash>, or L</update> because of the extra parameters that they require.
260  
261 =head2 ADVANCED SYNTAX
262  
263 Advanced syntax is used whenever a subroutine requires extra parameters besides just the query and bind values, or whenever you need to use L</encrypt>
264 or L</decrypt>. A simple example of the advanced syntax is:
265  
266 my $num_rows_updated = $db->raw(query => "UPDATE people SET name='Fred'");
267  
268 This is equivalent to:
269  
270 my $num_rows_updated = $db->raw("UPDATE people SET name='Fred'");
271  
272 A slightly more complex example adds in bind values:
273  
274 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?", vals => ['Fred']);
275  
276 This is equivalent to the simple syntax:
277  
278 my $num_rows_updated = $db->raw("UPDATE people SET name=?", 'Fred');
279  
280 Also, advanced syntax is required whenevery you want to L</encrypt> or L</decrypt> values.
281  
282 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?", vals => ['Fred'], encrypt => [0]);
283  
284 my $decrypted_name = $db->raw(query => "SELECT name FROM people WHERE id=1", decrypt => [0]);
285  
286 Note that L</"ADVANCED SYNTAX"> is required for L</hoh>, L</hoaoh>, L</hash>, or L</update> because of the extra parameters that they require.
287  
288 =head1 ENCRYPT AND DECRYPT
289  
290 You can use L<DBIx::Raw> to encrypt values when putting them into the database and decrypt values when removing them from the database.
291 Note that in order to store an encrypted value in the database, you should have the field be of type C<VARCHAR(255)> or some type of character
292 or text field where the encryption will fit. In order to encrypt and decrypt your values, L<DBIx::Raw> requires a L</crypt_key>. It contains a default
293 key, but it is recommended that you change it either by having a different one in your L</conf> file, or passing it in on creation with C<new> or setting it using the
294 L</crypt_key> method. It is recommended that you use a module like L<Crypt::Random> to generate a secure key.
295 One thing to note is that both L</encrypt> and L</decrypt> require L</"ADVANCED SYNTAX">.
296  
297 =head2 encrypt
298  
299 In order to encrypt values, the values that you want to encrypt must be in the bind values array reference that you pass into C<vals>. Note that for the values that you want to
300 encrypt, you should put their index into the encrypt array that you pass in. For example:
301  
302 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?,age=?,height=? WHERE id=1", vals => ['Zoe', 24, "5'11"], encrypt => [0, 2]);
303  
304 In the above example, only C<name> and C<height> will be encrypted. You can easily encrypt all values by using '*', like so:
305  
306 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?,height=? WHERE id=1", vals => ['Zoe', "5'11"], encrypt => '*');
307  
308 And this will encrypt both C<name> and C<height>.
309  
310 The only exception to the L</encrypt> syntax that is a little different is for L</update>. See L</"update encrypt"> for how to encrypt when using L</update>.
311  
312 =head2 decrypt
313  
314 When decrypting values, there are two possible different syntaxes.
315  
316 =head3 DECRYPT LIST CONTEXT
317  
318 If your query is returning a single value or values in a list context, then the array reference that you pass in for decrypt will contain the indices for the
319 order that the columns were listed in. For instance:
320  
321 my $name = $db->raw(query => "SELECT name FROM people WHERE id=1", decrypt => [0]);
322  
323 my ($name, $age) = $db->raw(query => "SELECT name, age FROM people WHERE id=1", decrypt => [0,1]);
324  
325 =head3 DECRYPT HASH CONTEXT
326  
327 When your query has L<DBIx::Raw> return your values in a hash context, then the columns that you want decrypted must be listed by name in the array reference:
328  
329 my $person = $db->raw(query => "SELECT name, age FROM people WHERE id=1", decrypt => ['name', 'age'])
330  
331 my $aoh = $db->aoh(query => "SELECT name, age FROM people", decrypt => ['name', 'age']);
332  
333 Note that for either L</"LIST CONTEXT"> or L</"HASH CONTEXT">, it is possible to use '*' to decrypt all columns:
334  
335 my ($name, $height) = $db->raw(query => "SELECT name, height FROM people WHERE id=1", decrypt => '*');
336  
337 =head2 crypt_key
338  
339 L<DBIx::Raw> uses L</"crypt_key"> to encrypt and decrypt all values. You can set the crypt key when you create your
340 L<DBIx::Raw> object by passing it into L</new>, providing it to L<CONFIGURATION FILE|DBIx::Raw/"CONFIGURATION FILE">,
341 or by setting it with its setter method:
342  
343 $db->crypt_key("1234");
344  
345 It is strongly recommended that you do not use the default L</"crypt_key">. The L</crypt_key> should be the appropriate length
346 for the L</crypt> that is set. The default L</crypt> uses L<Crypt::Mode::CBC::Easy>, which uses L<Crypt::Cipher::Twofish>, which
347 allows key sizes of 128/192/256 bits.
348  
349 =head2 crypt
350  
351 The L<Crypt::Mode::CBC::Easy> object to use for encryption. Default is the default L<Crypt::Mode::CBC::Easy> object
352 created with the key L</crypt_key>.
353  
354 =head2 use_old_crypt
355  
356 In version 0.16 L<DBIx::Raw> started using L<Crypt::Mode::CBC::Easy> instead of L<DBIx::Raw::Crypt>. Setting this to 1 uses the old encryption instead.
357 Make sure to set L</old_crypt_key> if you previously used L</crypt_key> for encryption.
358  
359 =head2 old_crypt_key
360  
361 This sets the crypt key to use if L</use_old_crypt> is set to true. Default is the previous crypt key.
362  
363 =head1 SUBROUTINES/METHODS
364  
365 =head2 raw
366  
367 L</raw> is a very versitile subroutine, and it can be called in three contexts. L</raw> should only be used to make a query that
368 returns values for one record, or a query that returns no results (such as an INSERT query). If you need to have multiple
369 results returned, see one of the subroutines below.
370  
371 =head3 SCALAR CONTEXT
372  
373 L</raw> can be called in a scalar context to only return one value, or in a undef context to return no value. Below are some examples.
374  
375 #select
376 my $name = $db->raw("SELECT name FROM people WHERE id=1");
377  
378 #update with number of rows updated returned
379 my $num_rows_updated = $db->raw("UPDATE people SET name=? WHERE id=1", 'Frank');
380
381 #update in undef context, nothing returned.
382 $db->raw("UPDATE people SET name=? WHERE id=1", 'Frank');
383  
384 #insert
385 $db->raw("INSERT INTO people (name, age) VALUES ('Jenny', 34)");
386  
387 Note that to L</decrypt> for L</"SCALAR CONTEXT"> for L</raw>, you would use L</"DECRYPT LIST CONTEXT">.
388  
389 =head3 LIST CONTEXT
390  
391 L</raw> can also be called in a list context to return multiple columns for one row.
392  
393 my ($name, $age) = $db->raw("SELECT name, age FROM people WHERE id=1");
394  
395 #or
396 my @person = $db->raw("SELECT name, age FROM people WHERE id=1");
397  
398 Note that to L</decrypt> for L</"LIST CONTEXT"> for L</raw>, you would use L</"DECRYPT LIST CONTEXT">.
399  
400 =head3 HASH CONTEXT
401  
402 L</raw> will return a hash if you are selecting more than one column for a single record.
403  
404 my $person = $db->raw("SELECT name, age FROM people WHERE id=1");
405 my $name = $person->{name};
406 my $age = $person->{age};
407  
408 Note that L</raw>'s L</"HASH CONTEXT"> works when using * in your query.
409  
410 my $person = $db->raw("SELECT * FROM people WHERE id=1");
411 my $name = $person->{name};
412 my $age = $person->{age};
413  
414 Note that to L</decrypt> for L</"HASH CONTEXT"> for L</raw>, you would use L</"DECRYPT HASH CONTEXT">.
415 =cut
416  
417 sub raw {
418 282 ▶ my $self = shift;
Subroutine raw: called CC=20 SCAR=30.6
Pod documented
419  
420 282 my $params = $self->_params(@_);
421  
422 282 my (@return_values, $return_type);
423 282 ▶ $self->sth($self->dbh->prepare($params->{query})) or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth($self->dbh->prepare($params->{"query"})) or $self->_perish($params) 0 282 282
424  
425 #if user asked for values to be encrypted
426 282 ▶ if($params->{encrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"encrypt"}) 157 125 282
427 157 $self->_crypt_encrypt($params);
428 }
429  
430 282 $self->_query($params);
431  
432 282 ▶ if(not defined wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined wantarray) { } 224 58 282
elsif (wantarray) { } 11 47 58
433 224 ▶ $self->sth->finish or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth->finish or $self->_perish($params) 0 224 224
434 224 return;
435 }
436 elsif(wantarray) {
437 11 $return_type = 'array';
438 }
439 else {
440 47 $return_type = 'scalar';
441  
442 47 ▶ if($params->{query} =~ /SELECT\s+(.*?)\s+FROM/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"query"} =~ /SELECT\s+(.*?)\s+FROM/i) 47 0 47
443 47 my $match = $1;
444 47 my $num_commas=()= $match =~ /,/g;
445 47 my $num_stars=()= $match =~ /\*/g;
446  
447 47 ▶ if($num_commas > 0 or $num_stars > 0) { $return_type = 'hash' }
Branch: 1 branch
BranchTrueFalseTotal
if ($num_commas > 0 or $num_stars > 0) 37 10 47
Condition100%3/3
$num_commas > 0 or $num_stars > 0
l!l&&r!l&&!r
35210
MC/DC100%2/2
$num_commas > 0 or $num_stars > 0
$num_commas > 0 $num_stars > 0
Truth table100%3/3
A or B
A= $num_commas > 0B= $num_stars > 0
ABresult
1X1
011
000
448 }
449 }
450  
451 58 ▶ if($params->{query} =~ /^(\n*?| *?|\r*?)UPDATE /si) {
Branch: 2 branches
BranchTrueFalseTotal
if ($params->{'query'} =~ /^(\n*?| *?|\r*?)UPDATE /is) { } 0 58 58
elsif ($params->{'query'} =~ /SELECT /sig or $params->{'query'} =~ /SHOW /sig) { } 58 0 58
452 0 my $return_value = $self->sth->rows();
453 0 push @return_values, $return_value;
454 }
455 ▶ elsif(($params->{query} =~ /SELECT /sig) || ($params->{query} =~ /SHOW /sig)) {
Condition33%1/3
$params->{"query"} =~ /SELECT /sig or $params->{"query"} =~ /SHOW /sig
l!l&&r!l&&!r
5800
MC/DC0%0/2
$params->{"query"} =~ /SELECT /sig or $params->{"query"} =~ /SHOW /sig
$params->{"query"} =~ /SELECT /sig $params->{"query"} =~ /SHOW /sig
Truth table33%1/3
A or B
A= $params->{"query"} =~ /SELECT /sigB= $params->{"query"} =~ /SHOW /sig
ABresult
1X1
011
000
456 58 ▶ unless($params->{query} =~ /INSERT INTO (.*?)SELECT /sig) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->{"query"} =~ /INSERT INTO (.*?)SELECT /sig) 58 0 58
457 58 ▶ if($return_type eq 'hash') {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_type eq 'hash') { } 37 21 58
458 37 ▶ return unless $params->{href} = $self->sth->fetchrow_hashref; #handles undef case
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"href"} = $self->sth->fetchrow_hashref 1 36 37
459  
460 36 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"decrypt"}) 8 28 36
461 8 $self->_crypt_decrypt($params);
462 }
463  
464 36 push @return_values, $params->{href};
465 }
466 else {
467 21 ▶ return unless @return_values = $self->sth->fetchrow_array(); #handles undef cases
Branch: 1 branch
BranchTrueFalseTotal
unless @return_values = $self->sth->fetchrow_array 2 19 21
468  
469 19 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"decrypt"}) 5 14 19
470 5 $params->{return_values} = \@return_values;
471 5 $self->_crypt_decrypt($params);
472 }
473 }
474 }
475 }
476  
477 55 ▶ $self->sth->finish or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth->finish or $self->_perish($params) 0 55 55
478  
479 55 ▶ unless($return_type eq 'array') {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_type eq 'array') { } 10 45 55
480 45 return $return_values[0];
481 }
482 else {
483 10 return @return_values;
484 }
485 }
486  
487 =head2 aoh (array_of_hashes)
488  
489 L</aoh> can be used to select multiple rows from the database. It returns an array reference of hashes, where each row is a hash in the array.
490  
491 my $people = $db->aoh("SELECT * FROM people");
492  
493 for my $person (@$people) {
494 print "$person->{name} is $person->{age} years old\n";
495 }
496  
497 Note that to L</decrypt> for L</aoh>, you would use L</"DECRYPT HASH CONTEXT">.
498 =cut
499  
500 sub aoh {
501 4 ▶ my $self = shift;
Subroutine aoh: called CC=4 SCAR=13.9
Pod documented
502 4 my $params = $self->_params(@_);
503 4 my ($href,@a);
504  
505 4 $self->_query($params);
506  
507 4 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 2 2 4
508 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 2 6
509 4 $params->{href} = $href;
510 4 $self->_crypt_decrypt($params);
511 4 push @a, $href;
512 }
513 }
514 else {
515 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 2 6
516 4 push @a, $href;
517 }
518 }
519  
520 4 return \@a;
521 }
522  
523 =head2 aoa (array_of_arrays)
524  
525 L</aoa> can be used to select multiple rows from the database. It returns an array reference of array references, where each row is an array within the array.
526  
527 my $people = $db->aoa("SELECT name,age FROM people");
528  
529 for my $person (@$people) {
530 my $name = $person->[0];
531 my $age = $person->[1];
532 print "$name is $age years old\n";
533 }
534  
535 Note that to L</decrypt> for L</aoa>, you would use L</"DECRYPT LIST CONTEXT">.
536 =cut
537  
538 sub aoa {
539 3 ▶ my $self = shift;
Subroutine aoa: called CC=4 SCAR=13.9
Pod documented
540 3 my $params = $self->_params(@_);
541 3 my (@return_values);
542  
543 3 $self->_query($params);
544  
545 3 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 2 3
546 1 ▶ while(my @a=$self->sth->fetchrow_array){
Branch: 1 branch
BranchTrueFalseTotal
if (my(@a) = $self->sth->fetchrow_array) 2 1 3
547 2 $params->{return_values} = \@a;
548 2 $self->_crypt_decrypt($params);
549 2 push @return_values, \@a;
550 }
551 }
552 else {
553 2 ▶ while(my @a=$self->sth->fetchrow_array){
Branch: 1 branch
BranchTrueFalseTotal
if (my(@a) = $self->sth->fetchrow_array) 4 2 6
554 4 push @return_values, \@a;
555 }
556 }
557  
558 3 return \@return_values;
559 }
560  
561  
562  
563 =head2 hoh (hash_of_hashes)
564  
565 =over
566  
567 =item
568  
569 B<query (required)> - the query
570  
571 =item
572  
573 B<key (required)> - the name of the column that will serve as the key to access each row
574  
575 =item
576  
577 B<href (optional)> - the hash reference that you would like to have the results added to
578  
579 =back
580  
581 L</hoh> can be used when you want to be able to access an individual row behind a unique key, where each row is represented as a hash. For instance,
582 this subroutine can be useful if you would like to be able to access rows by their id in the database. L</hoh> returns a hash reference of hash references.
583  
584 my $people = $db->hoh(query => "SELECT id, name, age FROM people", key => "id");
585  
586 for my $key(keys %$people) {
587 my $person = $people->{$key};
588 print "$person->{name} is $person->{age} years old\n";
589 }
590  
591 #or
592 while(my ($key, $person) = each %$people) {
593 print "$person->{name} is $person->{age} years old\n";
594 }
595  
596 So if you wanted to access the person with an id of 1, you could do so like this:
597  
598 my $person1 = $people->{1};
599 my $person1_name = $person1->{name};
600 my $person1_age = $person1->{age};
601  
602 Also, with L</hoh> it is possible to add to a previous hash of hashes that you alread have by passing it in with the C<href> key:
603  
604 #$people was previously retrieved, and results will now be added to $people
605 $db->hoh(query => "SELECT id, name, age FROM people", key => "id", href => $people);
606  
607 Note that you must select whatever column you want to be the key. So if you want to use "id" as the key, then you must select id in your query.
608 Also, keys must be unique or the records will overwrite one another. To retrieve multiple records and access them by the same key, see L<"hoaoh (hash_of_array_of_hashes)"/hoaoh>.
609 To L</decrypt> for L</hoh>, you would use L</"DECRYPT HASH CONTEXT">.
610  
611 =cut
612  
613 sub hoh {
614 3 ▶ my $self = shift;
Subroutine hoh: called CC=4 SCAR=13.9
Pod documented
615 3 my $params = $self->_params(@_);
616 3 my ($href);
617  
618 3 my $hoh = $params->{href}; #if hashref is passed in, it will just add to it
619  
620 3 $self->_query($params);
621  
622 3 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 2 3
623 1 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 2 1 3
624 2 $params->{href} = $href;
625 2 $self->_crypt_decrypt($params);
626 2 $hoh->{$href->{$params->{key}}} = $href;
627 }
628 }
629 else {
630 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 2 6
631 4 $hoh->{$href->{$params->{key}}} = $href;
632 }
633 }
634  
635 3 return $hoh;
636 }
637  
638 =head2 hoa (hash_of_arrays)
639  
640 =over
641  
642 =item
643  
644 B<query (required)> - the query
645  
646 =item
647  
648 B<key (required)> - the name of the column that will serve as the key to store the values behind
649  
650 =item
651  
652 B<val (required)> - the name of the column whose values you want to be stored behind key
653  
654 =item
655  
656 B<href (optional)> - the hash reference that you would like to have the results added to
657  
658 =back
659  
660 L</hoa> is useful when you want to store a list of values for one column behind a key. For instance,
661 say that you wanted the id's of all people who have the same name grouped together. You could perform that query like so:
662  
663 my $hoa = $db->hoa(query => "SELECT id, name FROM people", key => "name", val => "id");
664  
665 for my $name (%$hoa) {
666 my $ids = $hoa->{$name};
667  
668 print "$name has ids ";
669 for my $id (@$ids) {
670 print " $id,";
671 }
672  
673 print "\n";
674 }
675  
676 Note that you must select whatever column you want to be the key. So if you want to use "name" as the key, then you must select name in your query.
677 To L</decrypt> for L</hoa>, you would use L</"DECRYPT LIST CONTEXT">.
678  
679 =cut
680  
681 sub hoa {
682 3 ▶ my $self = shift;
Subroutine hoa: called CC=7 SCAR=19.8
Pod documented
683 3 my $params = $self->_params(@_);
684 3 my ($href);
685  
686 3 ▶ croak "query, key, and val are required for hoa" unless $params->{query} and $params->{key} and $params->{val};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"query"} and $params->{"key"} and $params->{"val"} 0 3 3
Condition33%2/6
$params->{"query"} and $params->{"key"} and $params->{"val"}
!ll&&!rl&&r
003
$params->{"query"} and $params->{"key"}
!ll&&!rl&&r
003
MC/DC0%0/3
$params->{"query"} and $params->{"key"} and $params->{"val"}
$params->{"query"} $params->{"key"} $params->{"val"}
Truth table25%1/4
A and B and C
A= $params->{"query"}B= $params->{"key"}C= $params->{"val"}
ABCresult
0XX0
10X0
1100
1111
687  
688 3 my $hash = $params->{href}; #if hash is passed in, it will just add to it
689  
690 3 $self->_query($params);
691  
692 3 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 2 3
693 1 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 1 5
694 4 $params->{href} = $href;
695 4 $self->_crypt_decrypt($params);
696 4 push @{$hash->{$href->{$params->{key}}}}, $href->{$params->{val}};
697 }
698 }
699 else {
700 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 8 2 10
701 8 push @{$hash->{$href->{$params->{key}}}}, $href->{$params->{val}};
702 }
703 }
704  
705 3 return $hash;
706 }
707  
708 =head2 hoaoh (hash_of_array_of_hashes)
709  
710 =over
711  
712 =item
713  
714 B<query (required)> - the query
715  
716 =item
717  
718 B<key (required)> - the name of the column that will serve as the key to store the array of hashes behind
719  
720 =item
721  
722 B<href (optional)> - the hash reference that you would like to have the results added to
723  
724 =back
725  
726 L</hoaoh> can be used when you want to store multiple rows behind a key that they all have in common. For
727 example, say that we wanted to have access to all rows for people that have the same name. That could be
728 done like so:
729  
730 my $hoaoh = $db->hoaoh(query => "SELECT id, name, age FROM people", key => "name");
731  
732 for my $name (keys %$hoaoh) {
733 my $people = $hoaoh->{$name};
734  
735 print "People named $name: ";
736 for my $person (@$people) {
737 print " $person->{name} is $person->{age} years old\n";
738 }
739  
740 print "\n";
741 }
742  
743 So to get the array of rows for all people named Fred, we could simply do:
744  
745 my @freds = $hoaoh->{Fred};
746  
747 for my $fred (@freds) { ... }
748  
749 Note that you must select whatever column you want to be the key. So if you want to use "name" as the key, then you must select name in your query.
750 To L</decrypt> for L</hoaoh>, you would use L</"DECRYPT HASH CONTEXT">.
751  
752 =cut
753  
754 sub hoaoh {
755 3 ▶ my $self = shift;
Subroutine hoaoh: called CC=6 SCAR=18.0
Pod documented
756 3 my $params = $self->_params(@_);
757 3 my ($href);
758  
759 3 ▶ croak "query and key are required for hoaoh" unless $params->{query} and $params->{key};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"query"} and $params->{"key"} 0 3 3
Condition33%1/3
$params->{"query"} and $params->{"key"}
!ll&&!rl&&r
003
MC/DC0%0/2
$params->{"query"} and $params->{"key"}
$params->{"query"} $params->{"key"}
Truth table33%1/3
A and B
A= $params->{"query"}B= $params->{"key"}
ABresult
0X0
100
111
760  
761 3 my $hoa = $params->{href}; #if hashref is passed it, it will just add to it
762  
763 3 $self->_query($params);
764  
765 3 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 2 3
766 1 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 1 5
767 4 $params->{href} = $href;
768 4 $self->_crypt_decrypt($params);
769 4 push @{$hoa->{$href->{$params->{key}}}},$href;
770 }
771 }
772 else {
773 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 8 2 10
774 8 push @{$hoa->{$href->{$params->{key}}}},$href;
775 }
776 }
777  
778 3 return $hoa;
779 }
780  
781 =head2 array
782  
783 L</array> can be used for selecting one value from multiple rows. Say for instance that we wanted all the ids for anyone named Susie.
784 We could do that like so:
785  
786 my $ids = $db->array("SELECT id FROM people WHERE name='Susie'");
787  
788 print "Susie ids: \n";
789 for my $id (@$ids) {
790 print "$id\n";
791 }
792  
793 To L</decrypt> for L</array>, you would use L</"DECRYPT LIST CONTEXT">.
794  
795 =cut
796  
797 sub array {
798 2 ▶ my $self = shift;
Subroutine array: called CC=4 SCAR=13.9
Pod documented
799 2 my $params = $self->_params(@_);
800 2 my ($r,@a);
801  
802 # Get the Array of results:
803 2 $self->_query($params);
804 2 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 1 2
805 1 ▶ while(($r) = $self->sth->fetchrow_array()){
Branch: 1 branch
BranchTrueFalseTotal
if (($r) = $self->sth->fetchrow_array) 4 1 5
806 4 $r = $self->_decrypt($r);
807 4 push @a, $r;
808 }
809 }
810 else {
811 1 ▶ while(($r) = $self->sth->fetchrow_array()){
Branch: 1 branch
BranchTrueFalseTotal
if (($r) = $self->sth->fetchrow_array) 4 1 5
812 4 push @a, $r;
813 }
814 }
815  
816 2 return \@a;
817 }
818  
819 =head2 hash
820  
821 =over
822  
823 =item
824  
825 B<query (required)> - the query
826  
827 =item
828  
829 B<key (required)> - the name of the column that will serve as the key
830  
831 =item
832  
833 B<val (required)> - the name of the column that will be stored behind the key
834  
835 =item
836  
837 B<href (optional)> - the hash reference that you would like to have the results added to
838  
839 =back
840  
841 L</hash> can be used if you want to map one key to one value for multiple rows. For instance, let's say
842 we wanted to map each person's id to their name:
843  
844 my $ids_to_names = $db->hash(query => "SELECT id, name FROM people", key => "id", val => "name");
845  
846 my $name_1 = $ids_to_names->{1};
847  
848 print "$name_1\n"; #prints 'Fred'
849  
850  
851 To have L</hash> add to an existing hash, just pass in the existing hash with C<href>:
852  
853  
854 $db->hash(query => "SELECT id, name FROM people", key => "id", val => "name", href => $ids_to_names);
855  
856 To L</decrypt> for L</hash>, you would use L</"DECRYPT HASH CONTEXT">.
857  
858 =cut
859  
860 sub hash {
861 3 ▶ my $self = shift;
Subroutine hash: called CC=7 SCAR=19.8
Pod documented
862 3 my $params = $self->_params(@_);
863 3 my ($href);
864  
865 3 ▶ croak "query, key, and val are required for hash" unless $params->{query} and $params->{key} and $params->{val};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"query"} and $params->{"key"} and $params->{"val"} 0 3 3
Condition33%2/6
$params->{"query"} and $params->{"key"} and $params->{"val"}
!ll&&!rl&&r
003
$params->{"query"} and $params->{"key"}
!ll&&!rl&&r
003
MC/DC0%0/3
$params->{"query"} and $params->{"key"} and $params->{"val"}
$params->{"query"} $params->{"key"} $params->{"val"}
Truth table25%1/4
A and B and C
A= $params->{"query"}B= $params->{"key"}C= $params->{"val"}
ABCresult
0XX0
10X0
1100
1111
866  
867 3 my $hash = $params->{href}; #if hash is passed in, it will just add to it
868  
869 3 $self->_query($params);
870  
871 3 ▶ if($params->{decrypt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'}) { } 1 2 3
872 1 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 2 1 3
873 2 $params->{href} = $href;
874 2 $self->_crypt_decrypt($params);
875 2 $hash->{$href->{$params->{key}}} = $href->{$params->{val}};
876 }
877 }
878 else {
879 2 ▶ while($href=$self->sth->fetchrow_hashref){
Branch: 1 branch
BranchTrueFalseTotal
if ($href = $self->sth->fetchrow_hashref) 4 2 6
880 4 $hash->{$href->{$params->{key}}} = $href->{$params->{val}};
881 }
882 }
883  
884 3 return $hash;
885 }
886  
887 =head2 insert
888  
889 =over
890  
891 =item
892  
893 B<href (required)> - the hash reference that will be used to insert the row, with the columns as the keys and the new values as the values
894  
895 =item
896  
897 B<table (required)> - the name of the table that the row will be inserted into
898  
899 =back
900  
901 L</insert> can be used to insert a single row with a hash. This can be useful if you already have the values you need
902 to insert the row with in a hash, where the keys are the column names and the values are the new values. This function
903 might be useful for submitting forms easily.
904  
905 my %person_to_insert = (
906 name => 'Billy',
907 age => '32',
908 favorite_color => 'blue',
909 );
910  
911 $db->insert(href => \%person_to_insert, table => 'people');
912  
913 If you need to have literal SQL into your insert query, then you just need to pass in a scalar reference. For example:
914  
915 "INSERT INTO people (name, update_time) VALUES('Billy', NOW())"
916  
917 If we had this:
918  
919 my %person_to_insert = (
920 name => 'Billy',
921 update_time => 'NOW()',
922 );
923  
924 $db->insert(href => \%person_to_insert, table => 'people');
925  
926 This would effectively evaluate to:
927  
928 $db->raw(query => "INSERT INTO people (name, update_time) VALUES(?, ?)", vals => ['Billy', 'NOW()']);
929  
930 However, this will not work. Instead, we need to do:
931  
932 my %person_to_insert = (
933 name => 'Billy',
934 update_time => \'NOW()',
935 );
936  
937 $db->insert(href => \%person_to_insert, table => 'people');
938  
939 Which evaluates to:
940  
941 $db->raw(query => "INSERT INTO people (name, update_time) VALUES(?, NOW())", vals => ['Billy']);
942  
943 And this is what we want.
944  
945 =head3 insert encrypt
946  
947 When encrypting for insert, because a hash is passed in you need to have the encrypt array reference contain the names of the columns that you want to encrypt
948 instead of the indices for the order in which the columns are listed:
949  
950 my %person_to_insert = (
951 name => 'Billy',
952 age => '32',
953 favorite_color => 'blue',
954 );
955  
956 $db->insert(href => \%person_to_insert, table => 'people', encrypt => ['name', 'favorite_color']);
957  
958 Note we do not ecnrypt age because it is most likely stored as an integer in the database.
959  
960 =cut
961  
962 # TODO: write insert tests
963 sub insert {
964 0 ▶ my $self = shift;
Subroutine insert: not called CC=9 SCAR=45.0
Pod documented
965 0 my $params = $self->_params(@_);
966  
967 0 ▶ croak "href and table are required for insert" unless $params->{href} and $params->{table};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"href"} and $params->{"table"} 0 0 0
Condition0%0/3
$params->{"href"} and $params->{"table"}
!ll&&!rl&&r
000
MC/DC0%0/2
$params->{"href"} and $params->{"table"}
$params->{"href"} $params->{"table"}
Truth table0%0/3
A and B
A= $params->{"href"}B= $params->{"table"}
ABresult
0X0
100
111
968  
969 0 my @vals;
970 0 my $column_names = '';
971 0 my $values_string = '';
972 0 my @encrypt;
973 0 ▶ while(my ($key,$val) = each %{$params->{href}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$params{"href"};}) 0 0 0
974 0 my $append = '?';
975 0 ▶ if (ref $val eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq 'SCALAR') { } 0 0 0
976 0 $append = $$val;
977 }
978 else {
979 0 ▶ if ($params->{encrypt} and first { $_ eq $key } @{$params->{encrypt}}) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})) 0 0 0
Condition0%0/3
$params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
!ll&&!rl&&r
000
MC/DC0%0/2
$params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
$params->{"encrypt"} &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
Truth table0%0/3
A and B
A= $params->{"encrypt"}B= &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
ABresult
0X0
100
111
980 0 push @encrypt, scalar(@vals);
981 }
982  
983 0 push @vals, $val;
984 }
985  
986 0 $column_names .= "$key,";
987 0 $values_string .= "$append,";
988 }
989
990 0 $column_names = substr $column_names, 0, -1;
991 0 $values_string = substr $values_string, 0, -1;
992  
993 0 $params->{query} = "INSERT INTO $params->{table} ($column_names) VALUES($values_string)";
994 0 $params->{vals} = \@vals;
995  
996 0 ▶ if ($params->{encrypt} and @encrypt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"encrypt"} and @encrypt) 0 0 0
Condition0%0/3
$params->{"encrypt"} and @encrypt
!ll&&!rl&&r
000
MC/DC0%0/2
$params->{"encrypt"} and @encrypt
$params->{"encrypt"} @encrypt
Truth table0%0/3
A and B
A= $params->{"encrypt"}B= @encrypt
ABresult
0X0
100
111
997 0 $params->{encrypt} = \@encrypt;
998 0 $self->_crypt_encrypt($params);
999 }
1000  
1001 0 $self->_query($params);
1002 }
1003  
1004 =head2 update
1005  
1006 =over
1007  
1008 =item
1009  
1010 B<href (required)> - the hash reference that will be used to update the row, with the columns as the keys and the new values as the values
1011  
1012 =item
1013  
1014 B<table (required)> - the name of the table that the updated row is in
1015  
1016 =item
1017  
1018 B<id (optional)> - specifies the id of the item that we are updating (note, column must be called "id"). Should not be used if C<pk> is used
1019  
1020 =item
1021  
1022 B<pk (optional)> - A hash reference of the form C<{name =E<gt> 'column_name', val =E<gt> 'unique_val'}>. Can be used instead of C<id>. Should not be used if C<id> is used
1023  
1024 =item
1025  
1026 B<where (optional)> - A where clause to help decide what row to update. Any bind values can be passed in with C<vals>
1027  
1028 =back
1029  
1030 L</update> can be used to update a single row with a hash, and returns the number of rows updated. This can be useful if you already have the values you need
1031 to update the row with in a hash, where the keys are the column names and the values are the new values. This function
1032 might be useful for submitting forms easily.
1033  
1034 my %updated_person = (
1035 name => 'Billy',
1036 age => '32',
1037 favorite_color => 'blue',
1038 );
1039  
1040 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', id => 1);
1041  
1042 # or in list context
1043 my ($num_rows_updated) = $db->update(href => \%updated_person, table => 'people', id => 1);
1044  
1045 Note that above for "id", the column must actually be named id for it to work. If you have a primary key or unique
1046 identifying column that is named something different than id, then you can use the C<pk> parameter:
1047  
1048 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', pk => {name => 'person_id', val => 1});
1049  
1050 If you need to specify more constraints for the row that you are updating instead of just the id, you can pass in a where clause:
1051  
1052 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', where => 'name=? AND favorite_color=? AND age=?', vals => ['Joe', 'green', 61]);
1053
1054 Note that any bind values used in a where clause can just be passed into the C<vals> as usual. It is possible to use a where clause and an id or pk together:
1055  
1056 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', where => 'name=? AND favorite_color=? AND age=?', vals => ['Joe', 'green', 61], id => 1);
1057  
1058 Alternatively, you could just put the C<id> or C<pk> in your where clause.
1059  
1060 If you need to have literal SQL into your update query, then you just need to pass in a scalar reference. For example:
1061  
1062 "UPDATE people SET name='Billy', update_time=NOW() WHERE id=1"
1063  
1064 If we had this:
1065  
1066 my %updated_person = (
1067 name => 'Billy',
1068 update_time => 'NOW()',
1069 );
1070  
1071 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', id => 1);
1072  
1073 This would effectively evaluate to:
1074  
1075 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?, update_time=? WHERE id=?", vals => ['Billy', 'NOW()', 1]);
1076  
1077 However, this will not work. Instead, we need to do:
1078  
1079 my %updated_person = (
1080 name => 'Billy',
1081 update_time => \'NOW()',
1082 );
1083  
1084 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', id => 1);
1085  
1086 Which evaluates to:
1087  
1088 my $num_rows_updated = $db->raw(query => "UPDATE people SET name=?, update_time=NOW() WHERE id=?", vals => ['Billy', 1]);
1089  
1090 And this is what we want.
1091  
1092 =head3 update encrypt
1093  
1094 When encrypting for update, because a hash is passed in you need to have the encrypt array reference contain the names of the columns that you want to encrypt
1095 instead of the indices for the order in which the columns are listed:
1096  
1097 my %updated_person = (
1098 name => 'Billy',
1099 age => '32',
1100 favorite_color => 'blue',
1101 );
1102  
1103 my $num_rows_updated = $db->update(href => \%updated_person, table => 'people', id => 1, encrypt => ['name', 'favorite_color']);
1104  
1105 Note we do not ecnrypt age because it is most likely stored as an integer in the database.
1106  
1107 =cut
1108  
1109 sub update {
1110 17 ▶ my $self = shift;
Subroutine update: called CC=19 SCAR=30.3
Pod documented
1111 17 my $params = $self->_params(@_);
1112  
1113 17 ▶ croak "href and table are required for update" unless $params->{href} and $params->{table};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"href"} and $params->{"table"} 0 17 17
Condition33%1/3
$params->{"href"} and $params->{"table"}
!ll&&!rl&&r
0017
MC/DC0%0/2
$params->{"href"} and $params->{"table"}
$params->{"href"} $params->{"table"}
Truth table33%1/3
A and B
A= $params->{"href"}B= $params->{"table"}
ABresult
0X0
100
111
1114  
1115 17 my @vals;
1116 17 my $string = '';
1117 17 my @encrypt;
1118 17 ▶ while(my ($key,$val) = each %{$params->{href}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$params{"href"};}) 51 17 68
1119 51 my $append = '?';
1120 51 ▶ if (ref $val eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq 'SCALAR') { } 3 48 51
1121 3 $append = $$val;
1122 }
1123 else {
1124 # TODO: write update encrypt tests
1125 48 ▶ if ((defined $params->{encrypt} and $params->{encrypt} eq '*')
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"encrypt"} and $params->{"encrypt"} eq "*" or $params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})) 24 24 48
Condition55%5/9
defined $params->{"encrypt"} and $params->{"encrypt"} eq "*" or $params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
l!l&&r!l&&!r
24024
defined $params->{"encrypt"} and $params->{"encrypt"} eq "*"
!ll&&!rl&&r
24024
$params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
!ll&&!rl&&r
2400
MC/DC0%0/4
defined $params->{"encrypt"} and $params->{"encrypt"} eq "*" or $params->{"encrypt"} and &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
defined $params->{"encrypt"} $params->{"encrypt"} eq "*" $params->{"encrypt"} &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
Truth table14%1/7
A and B or C and D
A= defined $params->{"encrypt"}B= $params->{"encrypt"} eq "*"C= $params->{"encrypt"}D= &first(sub { $_ eq $key; } , @{$$params{"encrypt"};})
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
1126 0 ▶ or ($params->{encrypt} and first { $_ eq $key } @{$params->{encrypt}})) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1127 24 push @encrypt, scalar(@vals);
1128 }
1129  
1130 48 push @vals, $val;
1131 }
1132  
1133 51 $string .= "$key=$append,";
1134 }
1135
1136 17 $string = substr $string, 0, -1;
1137  
1138 17 ▶ $params->{vals} = [] unless $params->{vals};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"vals"} 11 6 17
1139 17 my $where = '';
1140 17 ▶ if($params->{where}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"where"}) 10 7 17
1141 10 $where = " WHERE $params->{where}";
1142 10 push @vals, @{$params->{vals}};
1143 }
1144  
1145 17 ▶ if($params->{id}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($params->{'id'}) { } 5 12 17
elsif ($params->{'pk'}) { } 6 6 12
1146 5 ▶ if($where eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($where eq '') { } 3 2 5
1147 3 $where = " WHERE id=? ";
1148 }
1149 else {
1150 2 $where .= " AND id=? ";
1151 }
1152  
1153 5 push @vals, $params->{id};
1154 }
1155 elsif($params->{pk}) {
1156 6 my $name = $params->{pk}->{name};
1157 6 my $val = $params->{pk}->{val};
1158 6 ▶ if($where eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($where eq '') { } 2 4 6
1159 2 $where = " WHERE $name=? ";
1160 }
1161 else {
1162 4 $where .= " AND $name=? ";
1163 }
1164  
1165 6 push @vals, $val;
1166 }
1167  
1168 17 $params->{query} = "UPDATE $params->{table} SET $string $where";
1169 17 $params->{vals} = \@vals;
1170  
1171 17 ▶ if ($params->{encrypt} and @encrypt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"encrypt"} and @encrypt) 8 9 17
Condition66%2/3
$params->{"encrypt"} and @encrypt
!ll&&!rl&&r
908
MC/DC50%1/2
$params->{"encrypt"} and @encrypt
$params->{"encrypt"} @encrypt
Truth table66%2/3
A and B
A= $params->{"encrypt"}B= @encrypt
ABresult
0X0
100
111
1172 8 $params->{encrypt} = \@encrypt;
1173 8 $self->_crypt_encrypt($params);
1174 }
1175  
1176 17 $self->_query($params);
1177  
1178 17 ▶ return unless defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 17 0 17
1179 0 ▶ return wantarray ? ($self->sth->rows()) : $self->sth->rows();
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1180 }
1181  
1182 =head2 insert_multiple
1183  
1184 =over
1185  
1186 =item
1187  
1188 B<rows (required)> - the array reference of array references, where each inner array reference holds the values to be inserted for one row
1189  
1190 =item
1191  
1192 B<table (required)> - the name of the table that the rows are to be inserted into
1193  
1194 =item
1195  
1196 B<columns (required)> - The names of the columns that values are being inserted for
1197  
1198 =back
1199  
1200 L</insert_multiple> can be used to insert multiple rows with one query. For instance:
1201  
1202 my $rows = [
1203 [
1204 1,
1205 'Joe',
1206 23,
1207 ],
1208 [
1209 2,
1210 'Ralph,
1211 50,
1212 ],
1213 ];
1214  
1215 $db->insert_multiple(table => 'people', columns => [qw/id name age/], rows => $rows);
1216  
1217 This can be translated into the SQL query:
1218  
1219 INSERT INTO people (id, name, age) VALUES (1, 'Joe', 23), (2, 'Ralph', 50);
1220  
1221 Note that L</insert_multiple> does not yet support encrypt. I'm planning to add this feature later. If you need it now, please shoot me an email and I will
1222 try to speed things up!
1223  
1224 =cut
1225  
1226 sub insert_multiple {
1227 1 ▶ my $self = shift;
Subroutine insert_multiple: called CC=6 SCAR=18.2
Pod documented
1228 1 my $params = $self->_params(@_);
1229  
1230 1 ▶ while(my ($key, $val) = each %$params) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$params) 3 1 4
1231 3 print "$key=$val\n";
1232 }
1233  
1234 1 ▶ croak "columns, table, and rows are required for insert_multiple" unless $params->{columns} and $params->{table} and $params->{rows};
Branch: 1 branch
BranchTrueFalseTotal
unless $params->{"columns"} and $params->{"table"} and $params->{"rows"} 0 1 1
Condition33%2/6
$params->{"columns"} and $params->{"table"} and $params->{"rows"}
!ll&&!rl&&r
001
$params->{"columns"} and $params->{"table"}
!ll&&!rl&&r
001
MC/DC0%0/3
$params->{"columns"} and $params->{"table"} and $params->{"rows"}
$params->{"columns"} $params->{"table"} $params->{"rows"}
Truth table25%1/4
A and B and C
A= $params->{"columns"}B= $params->{"table"}C= $params->{"rows"}
ABCresult
0XX0
10X0
1100
1111
1235  
1236 1 my $values_string = '';
1237 1 my @vals;
1238  
1239 1 my $columns = join ',', @{$params->{columns}};
1240 1 my $row_string = '?,' x @{$params->{columns}};
1241 1 $row_string = substr $row_string, 0, -1;
1242  
1243 1 for my $row (@{$params->{rows}}) {
1244 2 push @vals, @$row;
1245 2 $values_string .= "($row_string),";
1246 }
1247  
1248 1 $values_string = substr $values_string, 0, -1;
1249  
1250 1 $params->{query} = "INSERT INTO $params->{table} ($columns) VALUES $values_string";
1251 1 print $params->{query} . "\n";
1252 1 $params->{vals} = \@vals;
1253  
1254 1 $self->_query($params);
1255 }
1256  
1257 =head2 sth
1258  
1259 L</sth> returns the statement handle from the previous query.
1260  
1261 my $sth = $db->sth;
1262  
1263 This can be useful if you need a statement handle to perform a function, like to get
1264 the id of the last inserted row.
1265  
1266 =cut
1267  
1268 =head2 dbh
1269  
1270 L</dbh> returns the database handle that L<DBIx::Raw> is using.
1271  
1272 my $dbh = $db->dbh;
1273  
1274 L</dbh> can also be used to set a new database handle for L<DBIx::Raw> to use.
1275  
1276 $db->dbh($new_dbh);
1277  
1278 =cut
1279  
1280 =head2 dsn
1281  
1282 L</dsn> returns the dsn that was provided.
1283  
1284 my $dsn = $db->dsn;
1285  
1286 L</dsn> can also be used to set a new C<dsn>.
1287  
1288 $db->dsn($new_dsn);
1289  
1290 When setting a new C<dsn>, it's likely you'll want to use L</connect>.
1291  
1292 =cut
1293  
1294 =head2 user
1295  
1296 L</user> returns the user that was provided.
1297  
1298 my $user = $db->user;
1299  
1300 L</user> can also be used to set a new C<user>.
1301  
1302 $db->user($new_user);
1303  
1304 When setting a new C<user>, it's likely you'll want to use L</connect>.
1305  
1306 =cut
1307  
1308 =head2 password
1309  
1310 L</password> returns the password that was provided.
1311  
1312 my $password = $db->password;
1313  
1314 L</password> can also be used to set a new C<password>.
1315  
1316 $db->password($new_password);
1317  
1318 When setting a new C<password>, it's likely you'll want to use L</connect>.
1319  
1320 =cut
1321  
1322 =head2 conf
1323  
1324 L</conf> returns the conf file that was provided.
1325  
1326 my $conf = $db->conf;
1327  
1328 L</conf> can also be used to set a new C<conf> file.
1329  
1330 $db->conf($new_conf);
1331  
1332 When setting a new C<conf>, it's likely you'll want to use L</connect>.
1333  
1334 =cut
1335  
1336 =head2 connect
1337  
1338 L</connect> can be used to keep the same L<DBIx::Raw> object, but get a new L</dbh>. You can call connect to get a new dbh with the same settings that you have provided:
1339  
1340 #now there is a new dbh with the same DBIx::Raw object using the same settings
1341 $db->connect;
1342  
1343 Or you can change the connect info.
1344 For example, if you update C<dsn>, C<user>, C<password>:
1345  
1346 $db->dsn('new_dsn');
1347 $db->user('user');
1348 $db->password('password');
1349  
1350 #get new dbh but keep same DBIx::Raw object
1351 $db->connect;
1352  
1353 Or if you update the conf file:
1354  
1355 $db->conf('/path/to/new_conf.pl');
1356
1357 #get new dbh but keep same DBIx::Raw object
1358 $db->connect;
1359  
1360 =cut
1361  
1362 sub connect {
1363 70 ▶ my ($self) = @_;
Subroutine connect: called CC=2 SCAR=7.4
Pod documented
1364  
1365 70 $self->_parse_conf;
1366 70 $self->_validate_connect_info;
1367 70 ▶ return $self->dbh(DBI->connect($self->dsn, $self->user, $self->password) or croak($DBI::errstr));
Condition33%1/3
'DBI'->connect($self->dsn, $self->user, $self->password) || croak($DBI::errstr)
l!l&&r!l&&!r
7000
MC/DC0%0/2
'DBI'->connect($self->dsn, $self->user, $self->password) || croak($DBI::errstr)
'DBI'->connect($self->dsn, $self->user, $self->password) croak($DBI::errstr)
Truth table33%1/3
A || B
A= 'DBI'->connect($self->dsn, $self->user, $self->password)B= croak($DBI::errstr)
ABresult
1X1
011
000
1368 }
1369  
1370 sub _params {
1371 321 ▶ my $self = shift;
Subroutine _params: called CC=2 SCAR=6.9
1372  
1373 321 my %params;
1374 321 ▶ unless($self->keys->{$_[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->keys->{$_[0]}) { } 278 43 321
1375 43 $params{query} = shift;
1376 43 $params{vals} = [@_];
1377 }
1378 else {
1379 278 %params = @_;
1380 }
1381  
1382 321 return \%params;
1383 }
1384  
1385 sub _query {
1386 321 ▶ my ($self, $params) = (@_);
Subroutine _query: called CC=5 SCAR=16.6
1387  
1388 321 ▶ $self->sth($self->dbh->prepare($params->{query})) or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth($self->dbh->prepare($params->{"query"})) or $self->_perish($params) 0 321 321
1389  
1390 321 ▶ if($params->{'vals'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'vals'}) { } 227 94 321
1391 227 ▶ $self->sth->execute(@{$params->{'vals'}}) or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth->execute(@{$$params{"vals"};}) or $self->_perish($params) 0 227 227
1392 }
1393 else {
1394 94 ▶ $self->sth->execute() or $self->_perish($params);
Branch: 1 branch
BranchTrueFalseTotal
$self->sth->execute or $self->_perish($params) 0 94 94
1395 }
1396 }
1397  
1398 sub _perish {
1399 0 ▶ my ($self, $params) = @_;
Subroutine _perish: not called CC=1 SCAR=6.9
1400 0 croak "ERROR: Can't prepare query.\n\n$DBI::errstr\n\nquery='" . $params->{query} . "'\n";
1401 }
1402  
1403 sub _crypt_decrypt {
1404 31 ▶ my ($self, $params) = @_;
Subroutine _crypt_decrypt: called CC=8 SCAR=20.8
1405 31 my @keys;
1406 31 ▶ if($params->{decrypt} eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'decrypt'} eq '*') { } 8 23 31
1407 8 ▶ if($params->{href}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'href'}) { } 6 2 8
1408 6 @keys = keys %{$params->{href}};
1409 }
1410 else {
1411 2 @keys = 0..$#{$params->{return_values}};
1412 }
1413 }
1414 else {
1415 23 @keys = @{$params->{decrypt}};
1416 }
1417  
1418 31 ▶ if($params->{href}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'href'}) { } 24 7 31
1419 24 for my $key (@keys) {
1420 47 ▶ $params->{href}->{$key} = $self->_decrypt($params->{href}->{$key}) if $params->{href}->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $params->{"href"}{$key} 47 0 47
1421 }
1422 }
1423 else {
1424 7 for my $index (@keys) {
1425 12 ▶ $params->{return_values}->[$index] = $self->_decrypt( $params->{return_values}->[$index] ) if $params->{return_values}->[$index];
Branch: 1 branch
BranchTrueFalseTotal
if $params->{"return_values"}[$index] 12 0 12
1426 }
1427 }
1428 }
1429  
1430 sub _crypt_encrypt {
1431 165 ▶ my ($self, $params) = @_;
Subroutine _crypt_encrypt: called CC=4 SCAR=13.9
1432 165 my @indices;
1433  
1434 165 ▶ if($params->{encrypt} eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'encrypt'} eq '*') { } 4 161 165
1435 4 my $num_question_marks = 0;
1436 #don't want to encrypt where conditions! Might be buggy...should look into this more
1437 4 ▶ if($params->{query} =~ /WHERE\s+(.*)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"query"} =~ /WHERE\s+(.*)/i) 4 0 4
1438 4 $num_question_marks =()= $1 =~ /=\s*?\?/g;
1439 }
1440  
1441 4 @indices = 0..($#{$params->{vals}} - $num_question_marks);
1442 }
1443 else {
1444 161 @indices = @{$params->{encrypt}};
1445 }
1446  
1447 165 for my $index (@indices) {
1448 80 @{$params->{vals}}[$index] = $self->_encrypt( @{$params->{vals}}[$index] );
1449 }
1450 }
1451  
1452 sub _encrypt {
1453 80 ▶ my ($self, $text) = @_;
Subroutine _encrypt: called CC=2 SCAR=7.6
1454  
1455 80 ▶ if ($self->use_old_crypt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->use_old_crypt) 0 80 80
1456 0 return $self->old_crypt->encrypt($text);
1457 }
1458  
1459 80 return $self->crypt->encrypt($text);
1460 }
1461  
1462 sub _decrypt {
1463 63 ▶ my ($self, $text) = @_;
Subroutine _decrypt: called CC=2 SCAR=7.6
1464
1465 63 ▶ if ($self->use_old_crypt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->use_old_crypt) 0 63 63
1466 0 return $self->old_crypt->decrypt($text);
1467 }
1468  
1469 63 return $self->crypt->decrypt($text);
1470 }
1471  
1472 sub _parse_conf {
1473 140 ▶ my ($self) = @_;
Subroutine _parse_conf: called CC=10 SCAR=23.4
1474  
1475 #load in configuration if it exists
1476 140 ▶ if($self->conf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf) 137 3 140
1477  
1478 #no need to read in settings again if conf hasn't changed, unless dsn, user, or password is unset
1479 137 ▶ return if $self->conf eq $self->prev_conf and $self->dsn and $self->user and $self->password;
Branch: 1 branch
BranchTrueFalseTotal
if $self->conf eq $self->prev_conf and $self->dsn and $self->user and $self->password 0 137 137
Condition77%7/9
$self->conf eq $self->prev_conf and $self->dsn and $self->user and $self->password
!ll&&!rl&&r
69680
$self->conf eq $self->prev_conf and $self->dsn and $self->user
!ll&&!rl&&r
69068
$self->conf eq $self->prev_conf and $self->dsn
!ll&&!rl&&r
68168
MC/DC0%0/4
$self->conf eq $self->prev_conf and $self->dsn and $self->user and $self->password
$self->conf eq $self->prev_conf $self->dsn $self->user $self->password
Truth table60%3/5
A and B and C and D
A= $self->conf eq $self->prev_confB= $self->dsnC= $self->userD= $self->password
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1480  
1481 137 my $config = Config::Any->load_files({files =>[$self->conf],use_ext => 1 });
1482  
1483 137 for my $c (@$config){
1484 137 for my $file (keys %$c){
1485 137 for my $attribute (keys %{$c->{$file}}){
1486 412 ▶ if($self->can($attribute)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($attribute)) 412 0 412
1487 412 $self->$attribute($c->{$file}->{$attribute});
1488 }
1489 }
1490 }
1491 }
1492  
1493 137 $self->prev_conf($self->conf);
1494 }
1495 }
1496  
1497 sub _validate_connect_info {
1498 140 ▶ my ($self) = @_;
Subroutine _validate_connect_info: called CC=5 SCAR=17.5
1499 140 ▶ croak "Need to specify 'dsn', 'user', and 'password' either when you create the object or by passing in a configuration file in 'conf'! Or, pass in an existing dbh"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->dsn and defined $self->user and defined $self->password or defined $self->dbh 0 140 140
Condition66%6/9
defined $self->dsn and defined $self->user and defined $self->password or defined $self->dbh
l!l&&r!l&&!r
13910
defined $self->dsn and defined $self->user and defined $self->password
!ll&&!rl&&r
10139
defined $self->dsn and defined $self->user
!ll&&!rl&&r
10139
MC/DC0%0/4
defined $self->dsn and defined $self->user and defined $self->password or defined $self->dbh
defined $self->dsn defined $self->user defined $self->password defined $self->dbh
Truth table28%2/7
A and B and C or D
A= defined $self->dsnB= defined $self->userC= defined $self->passwordD= defined $self->dbh
ABCDresult
111X1
0XX11
10X11
11011
0XX00
10X00
11000
1500 unless (defined $self->dsn and defined $self->user and defined $self->password) or defined $self->dbh;
1501 }
1502  
1503 =head1 AUTHOR
1504  
1505 Adam Hopkins, C<< <srchulo at cpan.org> >>
1506  
1507 =head1 BUGS
1508  
1509 Please report any bugs or feature requests to C<bug-dbix-raw at rt.cpan.org>, or through
1510 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Raw>. I will be notified, and then you'll
1511 automatically be notified of progress on your bug as I make changes.
1512  
1513 =head1 SUPPORT
1514  
1515 You can find documentation for this module with the perldoc command.
1516  
1517 perldoc DBIx::Raw
1518  
1519  
1520 You can also look for information at:
1521  
1522 =over 4
1523  
1524 =item * RT: CPAN's request tracker (report bugs here)
1525  
1526 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Raw>
1527  
1528 =item * AnnoCPAN: Annotated CPAN documentation
1529  
1530 L<http://annocpan.org/dist/DBIx-Raw>
1531  
1532 =item * CPAN Ratings
1533  
1534 L<http://cpanratings.perl.org/d/DBIx-Raw>
1535  
1536 =item * Search CPAN
1537  
1538 L<http://search.cpan.org/dist/DBIx-Raw/>
1539  
1540 =back
1541  
1542  
1543 =head1 ACKNOWLEDGEMENTS
1544  
1545 Special thanks to Jay Davis who wrote a lot of the original code that this module is based on.
1546  
1547 =head1 LICENSE
1548  
1549 This library is free software; you can redistribute it and/or modify
1550 it under the same terms as Perl itself.
1551  
1552 =cut
1553  
1554 71 1;
↑ Summary blib/lib/DBIx/Raw/Crypt.pm »