summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-09-17 11:31:51 +0000
committerfukachan <fukachan>2001-09-17 11:31:51 +0000
commit004409e9dce5256545f4f763d6f14b0f143248da (patch)
treeb0d4ba05582211a33c812e70515d8546beae0757 /fml/lib/IO/Adapter
parent700ec82a3b6f77c6b9e1da2a0f5b23b21af83e1f (diff)
downloadfml8-004409e9dce5256545f4f763d6f14b0f143248da.tar.gz
fml8-004409e9dce5256545f4f763d6f14b0f143248da.tar.bz2
fml8-004409e9dce5256545f4f763d6f14b0f143248da.zip
rename: fetch_and_cache_address_list -> fetch_all
implement md_find()
Diffstat (limited to 'fml/lib/IO/Adapter')
-rw-r--r--fml/lib/IO/Adapter/SQL/toymodel.pm52
1 files changed, 50 insertions, 2 deletions
diff --git a/fml/lib/IO/Adapter/SQL/toymodel.pm b/fml/lib/IO/Adapter/SQL/toymodel.pm
index 8b4cc218..6b50f246 100644
--- a/fml/lib/IO/Adapter/SQL/toymodel.pm
+++ b/fml/lib/IO/Adapter/SQL/toymodel.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: toymodel.pm,v 1.2 2001/08/05 03:24:45 fukachan Exp $
+# $FML: toymodel.pm,v 1.3 2001/08/05 12:07:23 fukachan Exp $
#
@@ -60,7 +60,7 @@ sub delete
}
-sub fetch_and_cache_address_list
+sub fetch_all
{
my ($self, $args) = @_;
@@ -71,6 +71,50 @@ sub fetch_and_cache_address_list
}
+sub md_find
+{
+ my ($self, $regexp, $args) = @_;
+ my $case_sensitive = $args->{ case_sensitive } ? 1 : 0;
+ my $show_all = $args->{ all } ? 1 : 0;
+ my (@buf, $x);
+
+ my $query = $self->_build_sql_query({
+ query => 'search',
+ regexp => $regexp,
+ });
+ $self->execute({ query => $query });
+
+ if (defined $self->{ _res }) {
+ my ($row);
+ while (defined ($row = $self->{ _res }->fetchrow_arrayref)) {
+ $x = join(" ", @$row);
+
+ if ($show_all) {
+ if ($case_sensitive) {
+ push(@buf, $x) if $x =~ /$regexp/;
+ }
+ else {
+ push(@buf, $x) if $x =~ /$regexp/i;
+ }
+ }
+ else {
+ if ($case_sensitive) {
+ last if $x =~ /$regexp/;
+ }
+ else {
+ last if $x =~ /$regexp/i;
+ }
+ }
+ }
+ }
+ else {
+ return undef;
+ }
+
+ $show_all ? \@buf : $x;
+}
+
+
# Descriptions:
#
# $args = {
@@ -104,6 +148,10 @@ sub _build_sql_query
elsif ($query eq 'delete') {
"delete from $table where ml='$ml_name' and address='$address'";
}
+ elsif ($query eq 'search') {
+ my $p = $args->{ 'regexp' };
+ "select address from $table where address like '\%${p}\%'";
+ }
else {
"select address from $table where ml='$ml_name' and file='$file'";
}