... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
0.1687 |
2 | 2 |
- added EXPERIMENTAL type_rule method |
3 | 3 |
- added EXPERIMENTAL execute() type_rule_off option |
4 |
+ - execute method can second argument as parameter |
|
4 | 5 |
0.1686 |
5 | 6 |
- select() column option can receive array reference in array. |
6 | 7 |
This is EXPERIMENTAL |
... | ... |
@@ -427,10 +427,15 @@ sub each_column { |
427 | 427 |
our %EXECUTE_ARGS = map { $_ => 1 } @COMMON_ARGS, 'param'; |
428 | 428 |
|
429 | 429 |
sub execute { |
430 |
- my ($self, $query, %args) = @_; |
|
430 |
+ my $self = shift; |
|
431 |
+ my $query = shift; |
|
432 |
+ my $param; |
|
433 |
+ $param = shift if @_ % 2; |
|
434 |
+ my %args = @_; |
|
431 | 435 |
|
432 | 436 |
# Arguments |
433 |
- my $param = delete $args{param} || {}; |
|
437 |
+ my $p = delete $args{param} || {}; |
|
438 |
+ $param ||= $p; |
|
434 | 439 |
my $tables = delete $args{table} || []; |
435 | 440 |
$tables = [$tables] unless ref $tables eq 'ARRAY'; |
436 | 441 |
my $filter = delete $args{filter}; |
... | ... |
@@ -1977,7 +1982,7 @@ column name and column information. |
1977 | 1982 |
|
1978 | 1983 |
my $result = $dbi->execute( |
1979 | 1984 |
"select * from book where title = :title and author like :author", |
1980 |
- param => {title => 'Perl', author => '%Ken%'} |
|
1985 |
+ {title => 'Perl', author => '%Ken%'} |
|
1981 | 1986 |
); |
1982 | 1987 |
|
1983 | 1988 |
Execute SQL, containing tags. |
... | ... |
@@ -163,6 +163,12 @@ $result = $dbi->execute($query, param => {key1 => 1, key2 => 3, key3 => 4, key4 |
163 | 163 |
$rows = $result->fetch_hash_all; |
164 | 164 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1"); |
165 | 165 |
|
166 |
+$source = "select * from table1 where {= key1} and {<> key2} and {< key3} and {> key4} and {>= key5};"; |
|
167 |
+$query = $dbi->create_query($source); |
|
168 |
+$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}); |
|
169 |
+$rows = $result->fetch_hash_all; |
|
170 |
+is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1"); |
|
171 |
+ |
|
166 | 172 |
$source = "select * from table1 where {<= key1} and {like key2};"; |
167 | 173 |
$query = $dbi->create_query($source); |
168 | 174 |
$result = $dbi->execute($query, param => {key1 => 1, key2 => '%2%'}); |