... | ... |
@@ -28,8 +28,12 @@ $class->add_format( |
28 | 28 |
# Methods |
29 | 29 |
sub utf8_filter_on { |
30 | 30 |
my $self = shift; |
31 |
+ |
|
32 |
+ # Set utf8 filters |
|
31 | 33 |
$self->bind_filter($self->filters->{encode_utf8}); |
32 | 34 |
$self->fetch_filter($self->filters->{decode_utf8}); |
35 |
+ |
|
36 |
+ return $self; |
|
33 | 37 |
} |
34 | 38 |
|
35 | 39 |
1; |
... | ... |
@@ -46,7 +50,23 @@ You can use all methods of L<DBIx::Custom> |
46 | 50 |
|
47 | 51 |
Please see L<DBIx::Custom> documentation |
48 | 52 |
|
49 |
-=head1 Filters |
|
53 |
+=head1 Methods |
|
54 |
+ |
|
55 |
+=head2 utf8_filter_on |
|
56 |
+ |
|
57 |
+Encode and decode utf8 filter on |
|
58 |
+ |
|
59 |
+ $self = $self->utf8_filter_on; |
|
60 |
+ |
|
61 |
+ # Sample |
|
62 |
+ $dbi->utf8_filter_on; |
|
63 |
+ |
|
64 |
+This equel to |
|
65 |
+ |
|
66 |
+ $dbi->bind_filter($dbi->filters->{encode_utf8}); |
|
67 |
+ $dbi->fetch_filter($dbi->filters->{decode_utf8}); |
|
68 |
+ |
|
69 |
+=head1 Available filters |
|
50 | 70 |
|
51 | 71 |
=head2 encode_utf8 |
52 | 72 |
|
... | ... |
@@ -66,7 +86,7 @@ This filter is generally used as fetch filter |
66 | 86 |
|
67 | 87 |
$dbi->fetch_filter($dbi->filters->{decode_utf8}); |
68 | 88 |
|
69 |
-=head2 Formats |
|
89 |
+=head2 Available formats |
|
70 | 90 |
|
71 | 91 |
strptime formats is available |
72 | 92 |
|
... | ... |
@@ -82,18 +102,6 @@ You get format as the following |
82 | 102 |
|
83 | 103 |
my $format = $dbi->formats->{$format_name}; |
84 | 104 |
|
85 |
-=head1 Methods |
|
86 |
- |
|
87 |
-=head2 utf8_filter_on |
|
88 |
- |
|
89 |
- # Encode and decode utf8 filter on |
|
90 |
- $dbi->utf8_filter_on; |
|
91 |
- |
|
92 |
-This equel to |
|
93 |
- |
|
94 |
- $dbi->bind_filter($dbi->filters->{encode_utf8}); |
|
95 |
- $dbi->fetch_filter($dbi->filters->{decode_utf8}); |
|
96 |
- |
|
97 | 105 |
=head1 AUTHOR |
98 | 106 |
|
99 | 107 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
... | ... |
@@ -58,7 +58,7 @@ DBIx::Custom::MySQL - DBIx::Custom MySQL implementation |
58 | 58 |
$dbi->insert('books', {title => 'perl', author => 'taro'}); |
59 | 59 |
|
60 | 60 |
# Update |
61 |
- # same as 'update books set (title = 'aaa', author = 'ken') where id = 5; |
|
61 |
+ # same as 'update books set title = 'aaa', author = 'ken' where id = 5; |
|
62 | 62 |
$dbi->update('books', {title => 'aaa', author => 'ken'}, {id => 5}); |
63 | 63 |
|
64 | 64 |
# Delete |
... | ... |
@@ -70,7 +70,7 @@ DBIx::Custom::MySQL - DBIx::Custom MySQL implementation |
70 | 70 |
# select * from books where ahthor = 'taro'; |
71 | 71 |
$dbi->select('books', {author => 'taro'}); |
72 | 72 |
|
73 |
-=head1 See DBIx::Custom and DBI::Custom::Basic documentation |
|
73 |
+=head1 See DBIx::Custom and DBI::Custom::Basic documentation at first |
|
74 | 74 |
|
75 | 75 |
This class is L<DBIx::Custom::Basic> subclass, |
76 | 76 |
and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass. |
... | ... |
@@ -82,14 +82,24 @@ Please see L<DBIx::Custom::Basic> and <DBIx::Custom> documentation. |
82 | 82 |
|
83 | 83 |
=head2 connect |
84 | 84 |
|
85 |
- This method override DBIx::Custom::connect |
|
85 |
+Connect to database |
|
86 |
+ |
|
87 |
+ $self = $self->connect; |
|
86 | 88 |
|
87 |
- If database attribute is set, automatically data source is created and connect |
|
89 |
+ # Sample |
|
90 |
+ $dbi->connect; |
|
91 |
+ |
|
92 |
+This override L<DBIx::Custom> connect. |
|
93 |
+ |
|
94 |
+If you set database, host, or port, data source is automatically created and connect |
|
88 | 95 |
|
89 | 96 |
=head2 last_insert_id |
90 | 97 |
|
91 |
- # Get last insert id |
|
92 | 98 |
$last_insert_id = $self->last_insert_id; |
99 |
+ |
|
100 |
+ # Sample |
|
101 |
+ $dbi->insert('books', {title => 'Perl', author => 'taro'}); |
|
102 |
+ $last_insert_id = $dbi->last_insert_id; |
|
93 | 103 |
|
94 | 104 |
This is equal to MySQL function |
95 | 105 |
|
... | ... |
@@ -42,49 +42,56 @@ DBIx::Custom::Query - DBIx::Custom query |
42 | 42 |
# Execute query |
43 | 43 |
$dbi->execute($query, $params); |
44 | 44 |
|
45 |
-=head1 OBJECT ACCESSORS |
|
45 |
+=head1 Accessors |
|
46 | 46 |
|
47 | 47 |
=head2 sth |
48 | 48 |
|
49 |
- # Set and get statement handle |
|
50 |
- $self = $query->sth($sql); |
|
51 |
- $sth = $query->sth; |
|
49 |
+Set and get statement handle |
|
50 |
+ |
|
51 |
+ $self = $self->sth($sql); |
|
52 |
+ $sth = $self->sth; |
|
52 | 53 |
|
53 | 54 |
=head2 sql |
54 | 55 |
|
55 |
- # Set and get SQL |
|
56 |
- $self = $query->sql($sql); |
|
57 |
- $sql = $query->sql; |
|
56 |
+Set and get SQL |
|
57 |
+ |
|
58 |
+ $self = $self->sql($sql); |
|
59 |
+ $sql = $self->sql; |
|
58 | 60 |
|
59 | 61 |
=head2 bind_filter |
60 | 62 |
|
61 |
- # Set and get bind filter |
|
62 |
- $self = $query->bind_filter($bind_filter); |
|
63 |
- $bind_filter = $query->bind_filter; |
|
63 |
+Set and get bind filter |
|
64 |
+ |
|
65 |
+ $self = $self->bind_filter($bind_filter); |
|
66 |
+ $bind_filter = $self->bind_filter; |
|
64 | 67 |
|
65 | 68 |
=head2 no_bind_filters |
66 | 69 |
|
67 |
- # Set and get keys of no filtering |
|
68 |
- $self = $query->no_bind_filters($no_filters); |
|
69 |
- $no_bind_filters = $query->no_bind_filters; |
|
70 |
+Set and get keys of no filtering |
|
71 |
+ |
|
72 |
+ $self = $self->no_bind_filters($no_filters); |
|
73 |
+ $no_bind_filters = $self->no_bind_filters; |
|
70 | 74 |
|
71 | 75 |
=head2 fetch_filter |
72 | 76 |
|
73 |
- # Set and get fetch filter |
|
74 |
- $self = $query->fetch_filter($fetch_filter); |
|
75 |
- $fetch_filter = $query->fetch_filter; |
|
77 |
+Set and get fetch filter |
|
78 |
+ |
|
79 |
+ $self = $self->fetch_filter($fetch_filter); |
|
80 |
+ $fetch_filter = $self->fetch_filter; |
|
76 | 81 |
|
77 | 82 |
=head2 no_fetch_filters |
78 | 83 |
|
79 |
- # Set and get keys of no filtering |
|
80 |
- $self = $query->no_fetch_filters($no_filters); |
|
81 |
- $no_fetch_filters = $query->no_fetch_filters; |
|
84 |
+Set and get keys of no filtering |
|
85 |
+ |
|
86 |
+ $self = $self->no_fetch_filters($no_filters); |
|
87 |
+ $no_fetch_filters = $self->no_fetch_filters; |
|
82 | 88 |
|
83 | 89 |
=head2 key_infos |
84 | 90 |
|
85 |
- # Set and get key informations |
|
86 |
- $self = $query->key_infos($key_infos); |
|
87 |
- $key_infos = $query->key_infos; |
|
91 |
+Set and get key informations |
|
92 |
+ |
|
93 |
+ $self = $self->key_infos($key_infos); |
|
94 |
+ $key_infos = $self->key_infos; |
|
88 | 95 |
|
89 | 96 |
=head1 AUTHOR |
90 | 97 |
|
... | ... |
@@ -9,12 +9,14 @@ use Carp 'croak'; |
9 | 9 |
sub _dbi : Attr {} |
10 | 10 |
sub sth : Attr {} |
11 | 11 |
sub fetch_filter : Attr {} |
12 |
-sub no_fetch_filters : Attr { type => 'array', trigger => sub { |
|
12 |
+ |
|
13 |
+sub no_fetch_filters : Attr { type => 'array', trigger => sub { |
|
13 | 14 |
my $self = shift; |
14 | 15 |
my $no_fetch_filters = $self->no_fetch_filters || []; |
15 | 16 |
my %no_fetch_filters_map = map {$_ => 1} @{$no_fetch_filters}; |
16 | 17 |
$self->_no_fetch_filters_map(\%no_fetch_filters_map); |
17 | 18 |
}} |
19 |
+ |
|
18 | 20 |
sub _no_fetch_filters_map : Attr {default => sub { {} }} |
19 | 21 |
|
20 | 22 |
# Fetch (array) |
... | ... |
@@ -197,7 +199,7 @@ Object::Simple->build_class; |
197 | 199 |
|
198 | 200 |
DBIx::Custom::Result - DBIx::Custom Resultset |
199 | 201 |
|
200 |
-=head1 SYNOPSIS |
|
202 |
+=head1 Synopsis |
|
201 | 203 |
|
202 | 204 |
# $result is DBIx::Custom::Result object |
203 | 205 |
my $dbi = DBIx::Custom->new; |
... | ... |
@@ -207,43 +209,40 @@ DBIx::Custom::Result - DBIx::Custom Resultset |
207 | 209 |
# do something |
208 | 210 |
} |
209 | 211 |
|
210 |
-=head1 OBJECT ACCESSORS |
|
212 |
+=head1 Accessors |
|
211 | 213 |
|
212 | 214 |
=head2 sth |
213 | 215 |
|
214 |
- # Set and Get statement handle |
|
216 |
+Set and Get statement handle |
|
217 |
+ |
|
215 | 218 |
$self = $result->sth($sth); |
216 | 219 |
$sth = $reuslt->sth |
217 |
- |
|
218 |
-Statement handle is automatically set by DBIx::Custom. |
|
219 |
-so you do not set statement handle. |
|
220 |
- |
|
221 |
-If you need statement handle, you can get statement handle by using this method. |
|
220 |
+ |
|
221 |
+ # Sample |
|
222 |
+ $dbi->sth->errstr |
|
222 | 223 |
|
223 | 224 |
=head2 fetch_filter |
224 | 225 |
|
225 |
- # Set and Get fetch filter |
|
226 |
+Set and Get fetch filter |
|
227 |
+ |
|
226 | 228 |
$self = $result->fetch_filter($sth); |
227 | 229 |
$fetch_filter = $result->fech_filter; |
228 | 230 |
|
229 |
-Statement handle is automatically set by DBIx::Custom. |
|
230 |
-If you want to set your fetch filter, you set it. |
|
231 |
- |
|
232 | 231 |
=head2 no_fetch_filters |
233 | 232 |
|
234 |
- # Set and Get no filter keys when fetching |
|
233 |
+Set and Get no filter keys when fetching |
|
234 |
+ |
|
235 | 235 |
$self = $result->no_fetch_filters($no_fetch_filters); |
236 | 236 |
$no_fetch_filters = $result->no_fetch_filters; |
237 | 237 |
|
238 |
-=head1 METHODS |
|
238 |
+=head1 Methods |
|
239 | 239 |
|
240 | 240 |
=head2 fetch |
241 | 241 |
|
242 |
- # Fetch row as array reference (Scalar context) |
|
243 |
- $row = $result->fetch; |
|
244 |
- |
|
245 |
- # Fetch row as array (List context) |
|
246 |
- @row = $result->fecth |
|
242 |
+Fetch a row |
|
243 |
+ |
|
244 |
+ $row = $self->fetch; # array reference |
|
245 |
+ @row = $self->fecth; # array |
|
247 | 246 |
|
248 | 247 |
# Sample |
249 | 248 |
while (my $row = $result->fetch) { |
... | ... |
@@ -252,15 +251,12 @@ If you want to set your fetch filter, you set it. |
252 | 251 |
my $val2 = $row->[1]; |
253 | 252 |
} |
254 | 253 |
|
255 |
-fetch method is fetch resultset and get row as array or array reference. |
|
256 |
- |
|
257 | 254 |
=head2 fetch_hash |
258 | 255 |
|
259 |
- # Fetch row as hash reference (Scalar context) |
|
260 |
- $row = $result->fetch_hash; |
|
261 |
- |
|
262 |
- # Fetch row as hash (List context) |
|
263 |
- %row = $result->fecth_hash |
|
256 |
+Fetch row as hash |
|
257 |
+ |
|
258 |
+ $row = $self->fetch_hash; # hash reference |
|
259 |
+ %row = $self->fecth_hash; # hash |
|
264 | 260 |
|
265 | 261 |
# Sample |
266 | 262 |
while (my $row = $result->fetch_hash) { |
... | ... |
@@ -269,85 +265,85 @@ fetch method is fetch resultset and get row as array or array reference. |
269 | 265 |
my $val2 = $row->{key2}; |
270 | 266 |
} |
271 | 267 |
|
272 |
-fetch_hash method is fetch resultset and get row as hash or hash reference. |
|
273 |
- |
|
274 | 268 |
=head2 fetch_first |
275 | 269 |
|
276 |
- # Fetch only first (Scalar context) |
|
277 |
- $row = $result->fetch_first; |
|
270 |
+Fetch only first row(Scalar context) |
|
271 |
+ |
|
272 |
+ $row = $self->fetch_first; # array reference |
|
273 |
+ @row = $self->fetch_first; # array |
|
278 | 274 |
|
279 |
- # Fetch only first (List context) |
|
280 |
- @row = $result->fetch_first; |
|
275 |
+ # Sample |
|
276 |
+ $row = $result->fetch_first; |
|
281 | 277 |
|
282 |
-This method fetch only first and finish statement handle |
|
278 |
+This method fetch only first row and finish statement handle |
|
283 | 279 |
|
284 | 280 |
=head2 fetch_hash_first |
285 | 281 |
|
286 |
- # Fetch only first as hash (Scalar context) |
|
287 |
- $row = $result->fetch_hash_first; |
|
282 |
+Fetch only first row as hash |
|
283 |
+ |
|
284 |
+ $row = $self->fetch_hash_first; # hash reference |
|
285 |
+ @row = $self->fetch_hash_first; # hash |
|
288 | 286 |
|
289 |
- # Fetch only first as hash (Scalar context) |
|
290 |
- @row = $result->fetch_hash_first; |
|
287 |
+ # Sample |
|
288 |
+ $row = $result->fetch_hash_first; |
|
291 | 289 |
|
292 |
-This method fetch only first and finish statement handle |
|
290 |
+This method fetch only first row and finish statement handle |
|
293 | 291 |
|
294 | 292 |
=head2 fetch_rows |
295 | 293 |
|
296 |
- # Fetch multi rows (Scalar context) |
|
297 |
- $rows = $result->fetch_rows($row_count); |
|
298 |
- |
|
299 |
- # Fetch multi rows (List context) |
|
300 |
- @rows = $result->fetch_rows($row_count); |
|
294 |
+Fetch rows |
|
295 |
+ |
|
296 |
+ $rows = $self->fetch_rows($row_count); # array ref of array ref |
|
297 |
+ @rows = $self->fetch_rows($row_count); # array of array ref |
|
301 | 298 |
|
302 |
- # Sapmle |
|
303 |
- $rows = $result->fetch_rows(10); |
|
299 |
+ # Sample |
|
300 |
+ while(my $rows = $result->fetch_rows(10)) { |
|
301 |
+ # do someting |
|
302 |
+ } |
|
304 | 303 |
|
305 | 304 |
=head2 fetch_hash_rows |
306 | 305 |
|
307 |
- # Fetch multi rows as hash (Scalar context) |
|
308 |
- $rows = $result->fetch_hash_rows($row_count); |
|
309 |
- |
|
310 |
- # Fetch multi rows as hash (List context) |
|
311 |
- @rows = $result->fetch_hash_rows($row_count); |
|
306 |
+Fetch rows as hash |
|
307 |
+ |
|
308 |
+ $rows = $self->fetch_hash_rows($row_count); # array ref of hash ref |
|
309 |
+ @rows = $self->fetch_hash_rows($row_count); # array of hash ref |
|
312 | 310 |
|
313 |
- # Sapmle |
|
314 |
- $rows = $result->fetch_hash_rows(10); |
|
311 |
+ # Sample |
|
312 |
+ while(my $rows = $result->fetch_hash_rows(10)) { |
|
313 |
+ # do someting |
|
314 |
+ } |
|
315 | 315 |
|
316 | 316 |
=head2 fetch_all |
317 | 317 |
|
318 |
- # Fetch all row as array ref of array ref (Scalar context) |
|
319 |
- $rows = $result->fetch_all; |
|
320 |
- |
|
321 |
- # Fetch all row as array of array ref (List context) |
|
322 |
- @rows = $result->fecth_all; |
|
318 |
+Fetch all rows |
|
319 |
+ |
|
320 |
+ $rows = $self->fetch_all; # array ref of array ref |
|
321 |
+ @rows = $self->fecth_all; # array of array ref |
|
323 | 322 |
|
324 | 323 |
# Sample |
325 | 324 |
my $rows = $result->fetch_all; |
326 |
- my $val0_0 = $rows->[0][0]; |
|
327 |
- my $val1_1 = $rows->[1][1]; |
|
328 |
- |
|
329 |
-fetch_all method is fetch resultset and get all rows as array or array reference. |
|
330 | 325 |
|
331 | 326 |
=head2 fetch_hash_all |
332 | 327 |
|
333 |
- # Fetch all row as array ref of hash ref (Scalar context) |
|
334 |
- $rows = $result->fetch_hash_all; |
|
335 |
- |
|
336 |
- # Fetch all row as array of hash ref (List context) |
|
337 |
- @rows = $result->fecth_all_hash; |
|
328 |
+Fetch all row as array ref of hash ref (Scalar context) |
|
329 |
+ |
|
330 |
+ $rows = $self->fetch_hash_all; # array ref of hash ref |
|
331 |
+ @rows = $self->fecth_all_hash; # array of hash ref |
|
338 | 332 |
|
339 | 333 |
# Sample |
340 | 334 |
my $rows = $result->fetch_hash_all; |
341 |
- my $val0_key1 = $rows->[0]{key1}; |
|
342 |
- my $val1_key2 = $rows->[1]{key2}; |
|
343 | 335 |
|
344 | 336 |
=head2 error |
345 | 337 |
|
346 |
- # Get error infomation |
|
347 |
- $error_messege = $result->error; |
|
348 |
- ($error_message, $error_number, $error_state) = $result->error; |
|
338 |
+Get error infomation |
|
339 |
+ |
|
340 |
+ $error_messege = $self->error; |
|
341 |
+ ($error_message, $error_number, $error_state) = $self->error; |
|
342 |
+ |
|
343 |
+ # Sample |
|
344 |
+ $error = $result->error; |
|
349 | 345 |
|
350 |
-You can get get information. This is crenspond to the following. |
|
346 |
+You can get get information. This is same as the following. |
|
351 | 347 |
|
352 | 348 |
$error_message : $result->sth->errstr |
353 | 349 |
$error_number : $result->sth->err |
... | ... |
@@ -355,24 +351,29 @@ You can get get information. This is crenspond to the following. |
355 | 351 |
|
356 | 352 |
=head2 finish |
357 | 353 |
|
358 |
- # Finish statement handle |
|
359 |
- $result->finish |
|
354 |
+Finish statement handle |
|
355 |
+ |
|
356 |
+ $ret_val = $self->finish |
|
360 | 357 |
|
361 | 358 |
# Sample |
362 |
- my $row = $reuslt->fetch; # fetch only one row |
|
359 |
+ my $row = $reuslt->fetch; # fetch a row |
|
363 | 360 |
$result->finish |
364 | 361 |
|
365 |
-You can finish statement handle.This is equel to |
|
362 |
+This is equel to |
|
366 | 363 |
|
367 | 364 |
$result->sth->finish; |
368 | 365 |
|
369 |
-=head1 AUTHOR |
|
366 |
+=head1 See also |
|
367 |
+ |
|
368 |
+L<DBIx::Custom> |
|
369 |
+ |
|
370 |
+=head1 Author |
|
370 | 371 |
|
371 | 372 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
372 | 373 |
|
373 | 374 |
Github L<http://github.com/yuki-kimoto> |
374 | 375 |
|
375 |
-=head1 COPYRIGHT & LICENSE |
|
376 |
+=head1 Copyright & licence |
|
376 | 377 |
|
377 | 378 |
Copyright 2009 Yuki Kimoto, all rights reserved. |
378 | 379 |
|
... | ... |
@@ -70,13 +70,13 @@ DBIx::Custom::SQLite - DBIx::Custom SQLite implementation |
70 | 70 |
|
71 | 71 |
# New |
72 | 72 |
my $dbi = DBIx::Custom::SQLite->new(user => 'taro', $password => 'kliej&@K', |
73 |
- database => 'sample.db'); |
|
73 |
+ database => 'sample'); |
|
74 | 74 |
|
75 | 75 |
# Insert |
76 | 76 |
$dbi->insert('books', {title => 'perl', author => 'taro'}); |
77 | 77 |
|
78 | 78 |
# Update |
79 |
- # same as 'update books set (title = 'aaa', author = 'ken') where id = 5; |
|
79 |
+ # same as 'update books set title = 'aaa', author = 'ken' where id = 5; |
|
80 | 80 |
$dbi->update('books', {title => 'aaa', author => 'ken'}, {id => 5}); |
81 | 81 |
|
82 | 82 |
# Delete |
... | ... |
@@ -95,7 +95,7 @@ DBIx::Custom::SQLite - DBIx::Custom SQLite implementation |
95 | 95 |
$dbi->select('books', [qw/author title/], {author => 'taro'}, |
96 | 96 |
'order by id limit 1'); |
97 | 97 |
|
98 |
-=head1 See DBIx::Custom and DBI::Custom::Basic documentation |
|
98 |
+=head1 See DBIx::Custom and DBI::Custom::Basic documentation at first |
|
99 | 99 |
|
100 | 100 |
This class is L<DBIx::Custom::Basic> subclass. |
101 | 101 |
and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass |
... | ... |
@@ -103,31 +103,48 @@ and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass |
103 | 103 |
You can use all methods of L<DBIx::Custom::Basic> and <DBIx::Custom> |
104 | 104 |
Please see L<DBIx::Custom::Basic> and <DBIx::Custom> documentation |
105 | 105 |
|
106 |
-=head1 Object methods |
|
106 |
+=head1 methods |
|
107 | 107 |
|
108 | 108 |
=head2 connect |
109 | 109 |
|
110 |
-This override L<DBIx::Custom> connect. |
|
110 |
+Connect to database |
|
111 | 111 |
|
112 |
- # Connect to database |
|
112 |
+ $self = $self->connect; |
|
113 |
+ |
|
114 |
+ # Sample |
|
113 | 115 |
$dbi->connect; |
114 | 116 |
|
115 |
-If database attribute is set, automatically data source is created and connect |
|
117 |
+This override L<DBIx::Custom> connect. |
|
118 |
+ |
|
119 |
+If you set database, data source is automatically created and connect |
|
116 | 120 |
|
117 | 121 |
=head2 connect_memory |
118 | 122 |
|
119 |
- # Connect memory database |
|
120 |
- $self = $dbi->connect_memory; |
|
123 |
+Connect memory database |
|
124 |
+ |
|
125 |
+ $self = $self->connect_memory; |
|
126 |
+ |
|
127 |
+ # Sample |
|
128 |
+ $dbi->connect_memory; |
|
121 | 129 |
|
122 | 130 |
=head2 reconnect_memory |
123 | 131 |
|
124 |
- # Reconnect memory database |
|
132 |
+Reconnect to memory databsse |
|
133 |
+ |
|
134 |
+ $self = $self->reconnect_memory; |
|
135 |
+ |
|
136 |
+ # Sample |
|
125 | 137 |
$self = $dbi->reconnect_memory; |
126 | 138 |
|
127 | 139 |
=head2 last_insert_id |
128 | 140 |
|
129 |
- # Get last insert id |
|
141 |
+Get last insert id |
|
142 |
+ |
|
130 | 143 |
$last_insert_id = $self->last_insert_id; |
144 |
+ |
|
145 |
+ # Sample |
|
146 |
+ $dbi->insert('books', {title => 'Perl', author => 'taro'}); |
|
147 |
+ $last_insert_id = $dbi->last_insert_id; |
|
131 | 148 |
|
132 | 149 |
This is equal to SQLite function |
133 | 150 |
|
... | ... |
@@ -44,6 +44,7 @@ my $dbi; |
44 | 44 |
my $decoded_str; |
45 | 45 |
my $encoded_str; |
46 | 46 |
my $array; |
47 |
+my $ret_val; |
|
47 | 48 |
|
48 | 49 |
use DBIx::Custom::Basic; |
49 | 50 |
|
... | ... |
@@ -52,9 +53,10 @@ $dbi = DBIx::Custom::Basic->new($NEW_ARGS->{0}); |
52 | 53 |
ok($dbi->filters->{encode_utf8}, "$test : exists default_bind_filter"); |
53 | 54 |
ok($dbi->filters->{decode_utf8}, "$test : exists default_fetch_filter"); |
54 | 55 |
|
55 |
-$dbi->utf8_filter_on; |
|
56 |
+$ret_val = $dbi->utf8_filter_on; |
|
56 | 57 |
is($dbi->bind_filter, $dbi->filters->{encode_utf8}, 'default bind filter'); |
57 | 58 |
is($dbi->fetch_filter, $dbi->filters->{decode_utf8}, 'default fetch filter'); |
59 |
+is(ref $ret_val, 'DBIx::Custom::Basic', "$test : retern value"); |
|
58 | 60 |
|
59 | 61 |
$decoded_str = 'あ'; |
60 | 62 |
$encoded_str = $dbi->bind_filter->($decoded_str); |