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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
"; |