/[pgestraier]/trunk/bin/pgest-index.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/pgest-index.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 63 by dpavlin, Mon Aug 7 14:30:55 2006 UTC revision 66 by dpavlin, Mon Aug 7 14:56:08 2006 UTC
# Line 22  my $c = { Line 22  my $c = {
22                  select ime,tel from imenik                  select ime,tel from imenik
23          },          },
24          pk_col => 'tel',          pk_col => 'tel',
         db_encoding => 'iso-8859-2',  
25          debug => 1,          debug => 1,
26          user => 'admin',          user => 'admin',
27          passwd => 'admin',          passwd => 'admin',
28  };  };
29    
30  GetOptions($c, qw/node_url=s sql=s pk_col=s eb_encoding=s debug+ user=s passwd=s/);  GetOptions($c, qw/node_url=s sql=s pk_col=s debug+ user=s passwd=s/);
31    
32  warn "# c: ", Dumper($c) if ($c->{debug});  warn "# c: ", Dumper($c) if ($c->{debug});
33    
# Line 106  while (my $row = $sth->fetchrow_hashref( Line 105  while (my $row = $sth->fetchrow_hashref(
105          while (my ($col,$val) = each %{$row}) {          while (my ($col,$val) = each %{$row}) {
106    
107                  if ($val) {                  if ($val) {
                         # change encoding?  
                         from_to($val, ($c->{db_encoding} || 'ISO-8859-1'), 'UTF-8');  
   
108                          # add attributes (make column usable from attribute search)                          # add attributes (make column usable from attribute search)
109                          $doc->add_attr($col, $val);                          $doc->add_attr($col, $val);
110    
# Line 130  while (my $row = $sth->fetchrow_hashref( Line 126  while (my $row = $sth->fetchrow_hashref(
126    
127  }  }
128    
129  my $cols = "'" . join("','", @cols) . "'";  my $cols = "'" . join("', '", @cols) . "'";
130    
131  foreach my $t (qw/UPDATE INSERT DELETE/) {  foreach my $t (qw/UPDATE INSERT DELETE/) {
132    
# Line 153  foreach my $t (qw/UPDATE INSERT DELETE/) Line 149  foreach my $t (qw/UPDATE INSERT DELETE/)
149  }  }
150    
151  $dbh->commit;  $dbh->commit;
152    
153    my $col_names = join(', ', @cols);
154    my $col_def = join(', ', map { "$_ text" } @cols);
155    
156    print "
157    ## example SQL search query:
158    
159    SELECT $col_names
160    FROM pgest(
161            -- node, login, passwd, depth
162            '$c->{node_url}', '$c->{user}', '$c->{passwd}', 0,
163            -- full text search
164            'foo bar',
165            -- attribute filter, order, limit, offset
166            null, null, null, null,
167            -- return columns
168            array[$cols]
169    ) as ($col_def);
170    
171    ";

Legend:
Removed from v.63  
changed lines
  Added in v.66

  ViewVC Help
Powered by ViewVC 1.1.26